[
https://issues.apache.org/jira/browse/WICKET-2206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12695862#action_12695862
]
Juha Paananen commented on WICKET-2206:
---------------------------------------
This is useful when the user navigates back to the page after visiting other
pages. In these cases the page isn't usually loaded from the server but from a
cache instead. Using an onload behavior you can perform a server-side check on
page validity. In my case I want to perform a check on the server side and if
the related business object (which is a request/order actually) is expired, I
redirect the user to an appropriate page.
Agreed that the thing here is simple, but then again, it took me several hours
to discover the right way of doing it, so wanted to contribute this to prevent
others from having to waste their precious time.. Anyway, if no-one else finds
this useful, then it's probably not worth including in the core. No great harm
done either way.
> 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.