What ?
Since version 6.0 Wicket uses JQuery as a backing library for its Ajax functionality.
Why ?
The previous implementations of wicket-ajax.js and wicket-event.js were home baked solutions that worked well but also suffered from the differences in the browsers. Often users complained that some functionality doesn't work on particular version of particular browser. That's why the Wicket team chose to use JQuery to deal with browser inconsistencies and leave us to do our business logic.
Design and implementation
The new implementations (wicket-ajax-jquery.js and wicket-event-jquery.js) use JQuery internally but expose Wicket.** API similar to the previous version.
All Java components and behaviors should still use the Wicket.** API. This way if someday we decide to not use JQuery anymore we will have less work to do. Also if a user uses Dojo/YUI/ExtJS/... and prefer to not have JQuery in her application then she will be able to provide wicket-ajax-xyz.js implementation and replace the default one.
Table with renamed methods from the previous version
1.5 |
6.0 |
---|---|
Wicket.fixEvent |
Wicket.Event.fix |
Wicket.stopEvent |
Wicket.Event.stop |
Wicket.show |
Wicket.DOM.show |
Wicket.showIncrementally |
Wicket.DOM.showIncrementally |
Wicket.hide |
Wicket.DOM.hide |
Wicket.hideIncrementally |
Wicket.DOM.hideIncrementally |
Wicket.decode |
Wicket.Head.Contributor.decode |
Wicket.ajaxGet, wicketAjaxGet |
Wicket.Ajax.get |
Wicket.ajaxPost, wicketAjaxPost |
Wicket.Ajax.post |
Wicket.submitForm |
Wicket.Ajax.submitForm |
Wicket.submitFormById |
Wicket.Ajax.submitForm |
Wicket.replaceOuterHtml |
Wicket.DOM.replace |
Wicket.Form.doSerialize |
Wicket.Form.serializeForm |
Link to jsdoc
TODO
Configuration
To replace any of the JavaScript files the user application may use:
MyApplication#init():
public void init() { super.init(); getJavaScriptLibrarySettings().setBackingLibraryReference(DojoReference.class); getJavaScriptLibrarySettings().setWicketEventReference(DojoWicketEventReference.class); getJavaScriptLibrarySettings().setWicketAjaxReference(DojoWicketAjaxReference.class); }
Since Wicket 6.0 ResourceReference can have dependencies and it is recommended to properly define the dependency chain between this classes.
See the code of org.apache.wicket.ajax.WicketAjaxJQueryResourceReference to see how the default JQuery based implementation does that.
If the user application needs to upgrade/downgrade to new/old version of JQuery then just the first line above is needed:
getJavaScriptLibrarySettings().setBackingLibraryReference(AnotherVersionOfJQueryReference.class);