OnLoadAjaxBehavior
------------------

                 Key: WICKET-2206
                 URL: https://issues.apache.org/jira/browse/WICKET-2206
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
    Affects Versions: 1.4-RC2
            Reporter: Juha Paananen
             Fix For: 1.5-M1


It would be convenient to have an OnLoadAjaxBehavior that can be used to 
execute server side code when page is loaded. For instance, I'm using this to 
check if the page has expired (the related user workflow has already finished). 
In short, here's the code:

public abstract class OnLoadAjaxBehavior extends AbstractDefaultAjaxBehavior {
    private static final long serialVersionUID = 1L;

    @Override
    public void renderHead(final IHeaderResponse response) {
        StringBuilder javascript = new StringBuilder();
        javascript.append("wicketAjaxGet('" + getCallbackUrl() + "', function() 
{}, function() { });\n");
        response.renderOnLoadJavascript(javascript.toString());
    }
}

This leaves the respond(..) method abstract. The concrete classes will add the 
server behavior in their implementations of the respond(..) method.

For me it took several hours to find out how to do this relatively simple 
thing. If we had this behavior class in Wicket, it would save some time for 
other n00bs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to