Hi,

is it possible to intercept component event actions?

I have one page with multiple zones. Blocks from another page rendered on
these zones using ajax.
Those blocks have components with event action handlers.
Every action handler have context parameter, and I would like to check
these params before action gets executed and, possibly, substitute another
action output.

Normally I'd use page's onActivate method for this, but since blocks are on
the other page -- onActivate doesn't get invoked for that page.
Now I have to repeat the code in order to do checks (see code below), but
I'd really like to intercept these calls.

Just can't find how to do this. Or I'm I doing something wrong and this can
be done in some other way?

public class PageWithBlocks {

    private Project project;

    ...

    public Object onActionFromCheckout(int projectId) {
        //  XXX Code smells (DRY)
        if (project == null)
        {
            Object response = resolveProject(projectId);
            if (project == null) {
                return response;
            }
        }

        projectManager.scheduleCheckout(project);

        return settingsBlock;
    }

    public Object onActionFromUpdate(int projectId) {
        //  XXX Code smells (DRY)
        if (project == null)
        {
            Object response = resolveProject(projectId);
            if (project == null) {
                return response;
            }
        }

        projectManager.scheduleUpdate(project);

        return settingsBlock;
    }
}

-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

Reply via email to