You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Martin Grigorov <mg...@apache.org> on 2013/03/08 14:24:02 UTC

Short/stable urls for (Ajax)behaviors

Hi,

Some users asked how to make it simpler JavaScript libraries to request
Wicket behaviors (ajax or not) simpler, for example "by name".

Currently if a JS library needs a server endpoint to get/put data the
application should provide a mounted IResource or the application developer
should provide the behavior's url
(IBehaviorListener/AjaxBehavior#getCallbackUrl()) in some TextTemplate.

In https://issues.apache.org/jira/browse/WICKET-5087 there is a simple
patch that adds a new method to Wicket.Ajax.** namespace which can be used
from any JS code:

var attrs = {
  su: "some/nice/url",
  ... // other supported Ajax attributes
}
Wicket.Ajax.short(attrs)

A new AjaxEventBehavior is implemented which should be added to the page
that delegates the calls. Current impl in the patch uses an additional
method to AbstractDefaultAjaxBehavior but this can be re-done with other
means (look for special annotation or a new interface for example).

The Ajax behaviors still work as they do now, they still bind event
listeners which call the server by using the callbackUrl.
The new method simplifies the calls to the server from anywhere else.


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>