[CONF] Apache Wicket Wicket Ajax
Wicket Ajax Page edited by Martin Grigorov Comment: Add an entry for the new Ajax attribute - EventPropagation Changes (1) ... | request timeout | a timeout to abort the request if there is no response. | 0 (no timeout) | rt | | allow default | a boolean flag which indicates whether to allow the default behavior of the HTML element which listens for the event. For example: clicking on Ajax checkbox should allow the default behavior to actually check the box. | false | ad | | stop propagation | an enum which controls whether to stop the propagation of the _javascript_ event to its targets parent nodes. Possible values: STOP, STOP_IMMEDIATELY, BUBBLE. | STOP | sp | | async | a boolean flag that indicates whether the Ajax call should be asynchronous or not. | true | async | | throttling settings | settings which define whether the Ajax call should be throttled and for how long. See the javadoc of org.apache.wicket.ajax.attributes.ThrottlingSettings for more information. | no throttling | tr | ... Full Content What ? Why ? Design and implementation Table with renamed methods from the previous version Configuration Setup Resource dependencies AjaxRequestAttributes Migration steps o.a.w.ajax.IAjaxCallDecorator is replaced with o.a.w.ajax.attributes.IAjaxCallListener. Global Ajax call listeners Automatically migrated attributes. Tests for the client side Wicket Ajax functionality Blog articles FAQ How to check whether my custom version of the backing _javascript_ library (jQuery) doesn't break Wicket internals somehow ? What parameters are passed to the handlers ? How to use the preconditions with non-native/_javascript_-based confirm dialogs ? 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 Configuration Setup To replace any of the _javascript_ files the user application may use: MyApplication#init(): public void init() { super.init(); IJavaScriptLibrarySettings jsSettings = getJavaScriptLibrarySettings(); jsSettings.setJQueryReference(new MyJQueryReference()); jsSettings.setWicketEventReference(new DojoWicketEventReference()); jsSettings.setWicketAjaxReference(new DojoWicketAjaxReference()); } Resource dependencies 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().setJQueryReference(new AnotherVersionOfJQueryReference()); If the user application needs to use Dojo instead of jQuery then it has provide _javascript_ResourceReferences for wicket-event-dojo.js and wicket-ajax-dojo.js (e.g. DojoWicketEventReference and DojoWicketAjaxReference). Those references should define dependency to
[CONF] Apache Wicket Wicket Ajax
Wicket Ajax Page edited by Geoff Hayman Changes (2) ... protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(AjaxRequestAttributes attributes); super.updateAjaxAttributes(attributes); AjaxCallListener myAjaxCallListener = new AjaxCallListener() { ... Full Content What ? Why ? Design and implementation Table with renamed methods from the previous version Configuration Setup Resource dependencies AjaxRequestAttributes Migration steps o.a.w.ajax.IAjaxCallDecorator is replaced with o.a.w.ajax.attributes.IAjaxCallListener. Global Ajax call listeners Automatically migrated attributes. Tests for the client side Wicket Ajax functionality Blog articles FAQ How to check whether my custom version of the backing _javascript_ library (jQuery) doesn't break Wicket internals somehow ? What parameters are passed to the handlers ? How to use the preconditions with non-native/_javascript_-based confirm dialogs ? 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 Configuration Setup To replace any of the _javascript_ files the user application may use: MyApplication#init(): public void init() { super.init(); IJavaScriptLibrarySettings jsSettings = getJavaScriptLibrarySettings(); jsSettings.setJQueryReference(new MyJQueryReference()); jsSettings.setWicketEventReference(new DojoWicketEventReference()); jsSettings.setWicketAjaxReference(new DojoWicketAjaxReference()); } Resource dependencies 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().setJQueryReference(new AnotherVersionOfJQueryReference()); If the user application needs to use Dojo instead of JQuery then it has provide _javascript_ResourceReferences for wicket-event-dojo.js and wicket-ajax-dojo.js (e.g. DojoWicketEventReference and DojoWicketAjaxReference). Those references should define dependency to DojoReference (a reference that delivers dojo.js). Wicket uses IJavaScriptLibrarySettings#getWicketAjaxReference() and all its transitive dependencies for its _javascript_ needs. AjaxRequestAttributes Each Ajax behavior and component can use o.a.w.ajax.attributes.AjaxRequestAttributes to configure how exactly the Ajax call should be executed and how its response should be handled. To do this use: AnyAjaxComponent/AnyAjaxBehavior.java: protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(AjaxRequestAttributes attributes); attributes.[set some attribute](); } The available attributes are: Name Description Default value
[CONF] Apache Wicket Wicket Ajax
Wicket Ajax Page edited by Geoff Hayman Changes (2) ... AjaxCallListener myAjaxCallListener = new AjaxCallListener() { @Override public CharSequence getBeforeHandler(Component component) { return alert(I\m executed before the firing of the Ajax call); } @Overridepublic CharSequence getBeforeHandler(Component component) {return alert(I\m executed before the firing of the Ajax call);} }; attributes.getAjaxCallListeners().add(myAjaxCallListener); ... Full Content What ? Why ? Design and implementation Table with renamed methods from the previous version Configuration Setup Resource dependencies AjaxRequestAttributes Migration steps o.a.w.ajax.IAjaxCallDecorator is replaced with o.a.w.ajax.attributes.IAjaxCallListener. Global Ajax call listeners Automatically migrated attributes. Tests for the client side Wicket Ajax functionality Blog articles FAQ How to check whether my custom version of the backing _javascript_ library (jQuery) doesn't break Wicket internals somehow ? What parameters are passed to the handlers ? How to use the preconditions with non-native/_javascript_-based confirm dialogs ? 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 Configuration Setup To replace any of the _javascript_ files the user application may use: MyApplication#init(): public void init() { super.init(); IJavaScriptLibrarySettings jsSettings = getJavaScriptLibrarySettings(); jsSettings.setJQueryReference(new MyJQueryReference()); jsSettings.setWicketEventReference(new DojoWicketEventReference()); jsSettings.setWicketAjaxReference(new DojoWicketAjaxReference()); } Resource dependencies 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().setJQueryReference(new AnotherVersionOfJQueryReference()); If the user application needs to use Dojo instead of JQuery then it has provide _javascript_ResourceReferences for wicket-event-dojo.js and wicket-ajax-dojo.js (e.g. DojoWicketEventReference and DojoWicketAjaxReference). Those references should define dependency to DojoReference (a reference that delivers dojo.js). Wicket uses IJavaScriptLibrarySettings#getWicketAjaxReference() and all its transitive dependencies for its _javascript_ needs. AjaxRequestAttributes Each Ajax behavior and component can use o.a.w.ajax.attributes.AjaxRequestAttributes to configure how exactly the Ajax call should be executed and how its response should be handled. To do this use: AnyAjaxComponent/AnyAjaxBehavior.java: protected void
[CONF] Apache Wicket Wicket Ajax
Wicket Ajax Page edited by Alexander Lipatov Changes (3) ... {code} Many of the attributes have default values which are not written in the JSON settings and they are initialized at the client side (i.e. wicket-ajax.js knows the defaults). The example above can be read as: when HTML element with id linkId is clicked fire an Ajax call with Url the/url/to/the/link. If you need more examples how to use it from JS, take a look at [#wicket sources#faq]: wicket-core/src/test/js/ajax.js ... An introduction to the new functionalities are described at [Wicket In Action|http://wicketinaction.com/2012/07/wicket-6-_javascript_-improvements/]. There is also a link to a demo application. h3. FAQ {anchor:faq} h4. How to check whether my custom version of the backing _javascript_ library (jQuery) doesnt break Wicket internals somehow ? # Clone Wicket {anchor:wicket sources} from its Git repository git clone [http://git-wip-us.apache.org/repos/asf/wicket.git] # Open _wicket-core/src/test/js/all.html_ and change it to point to your version of the backing library. ... Full Content What ? Why ? Design and implementation Table with renamed methods from the previous version Configuration Setup Resource dependencies AjaxRequestAttributes Migration steps o.a.w.ajax.IAjaxCallDecorator is replaced with o.a.w.ajax.attributes.IAjaxCallListener. Global Ajax call listeners Automatically migrated attributes. Tests for the client side Wicket Ajax functionality Blog articles FAQ How to check whether my custom version of the backing _javascript_ library (jQuery) doesn't break Wicket internals somehow ? What parameters are passed to the handlers ? 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 Configuration Setup To replace any of the _javascript_ files the user application may use: MyApplication#init(): public void init() { super.init(); IJavaScriptLibrarySettings jsSettings = getJavaScriptLibrarySettings(); jsSettings.setJQueryReference(new MyJQueryReference()); jsSettings.setWicketEventReference(new DojoWicketEventReference()); jsSettings.setWicketAjaxReference(new DojoWicketAjaxReference()); } Resource dependencies 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().setJQueryReference(new AnotherVersionOfJQueryReference()); If the user application needs to use Dojo instead of JQuery then it has provide _javascript_ResourceReferences for wicket-event-dojo.js and wicket-ajax-dojo.js (e.g. DojoWicketEventReference and DojoWicketAjaxReference). Those references should
[CONF] Apache Wicket Wicket Ajax rewriting
Wicket Ajax rewriting Page moved by Adam A. Koch From: Apache Wicket Index To: Apache Wicket Framework Documentation Children moved Change Notification Preferences View Online | Add Comment
[CONF] Apache Wicket Wicket Ajax
Wicket Ajax Page edited by Martin Grigorov Comment: Explain how to replace JQuery with another JS lib Changes (2) ... IJavaScriptLibrarySettings jsSettings = getJavaScriptLibrarySettings(); jsSettings.setJQueryReference(new DojoReference()); MyJQueryReference()); jsSettings.setWicketEventReference(new DojoWicketEventReference()); ... {code} If the user application needs to use Dojo instead of JQuery then it has provide _javascript_ResourceReferences for wicket-event-dojo.js and wicket-ajax-dojo.js (e.g. DojoWicketEventReference and DojoWicketAjaxReference). Those references should define dependency to DojoReference (a reference that delivers dojo.js). Wicket uses IJavaScriptLibrarySettings#getWicketAjaxReference() and all its transitive dependencies for its _javascript_ needs. h3. AjaxRequestAttributes ... Full Content What ? Why ? Design and implementation Table with renamed methods from the previous version Configuration Setup Resource dependencies AjaxRequestAttributes Migration steps o.a.w.ajax.IAjaxCallDecorator is replaced with o.a.w.ajax.attributes.IAjaxCallListener. Global Ajax call listeners Automatically migrated attributes. Tests for the client side Wicket Ajax functionality Blog articles FAQ How to check whether my custom version of the backing _javascript_ library (jQuery) doesn't break Wicket internals somehow ? What parameters are passed to the handlers ? 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 Configuration Setup To replace any of the _javascript_ files the user application may use: MyApplication#init(): public void init() { super.init(); IJavaScriptLibrarySettings jsSettings = getJavaScriptLibrarySettings(); jsSettings.setJQueryReference(new MyJQueryReference()); jsSettings.setWicketEventReference(new DojoWicketEventReference()); jsSettings.setWicketAjaxReference(new DojoWicketAjaxReference()); } Resource dependencies 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().setJQueryReference(new AnotherVersionOfJQueryReference()); If the user application needs to use Dojo instead of JQuery then it has provide _javascript_ResourceReferences for wicket-event-dojo.js and wicket-ajax-dojo.js (e.g. DojoWicketEventReference and DojoWicketAjaxReference). Those references should define dependency to DojoReference (a reference that delivers dojo.js). Wicket uses IJavaScriptLibrarySettings#getWicketAjaxReference() and all its transitive dependencies for its _javascript_ needs. AjaxRequestAttributes
[CONF] Apache Wicket Wicket Ajax
Wicket Ajax Page edited by Martin Grigorov Comment: Add FAQ section Changes (1) ... At [ajax.js|http://git-wip-us.apache.org/repos/asf/wicket/repo?p=wicket.git;a=blob;f=wicket-core/src/test/js/ajax.js;hb=master] you may see the currently available _javascript_ unit tests that we have for the Ajax functionality in wicket-ajax.js h3. FAQ h4. How to check whether my custom version of the backing _javascript_ library (jQuery) doesnt break Wicket internals somehow ? # Clone Wicket from its Git repositorygit clone http://git-wip-us.apache.org/repos/asf/wicket.git # Open _wicket-core/src/test/js/all.html_ and change it to point to your version of the backing library. # Run the non-Ajax tests by opening _file:///path/to/wicket/wicket-core/src/test/js/all.html_ # To run the Ajax tests see the description at the top of _wicket-core/src/test/js/ajax.js_. It is required to run them through Web Server Full Content What ? Why ? Design and implementation Table with renamed methods from the previous version Configuration Setup Resource dependencies AjaxRequestAttributes Migration steps o.a.w.ajax.IAjaxCallDecorator is replaced with o.a.w.ajax.attributes.IAjaxCallListener. Global Ajax call listeners Automatically migrated attributes. Tests for the client side Wicket Ajax functionality FAQ How to check whether my custom version of the backing _javascript_ library (jQuery) doesn't break Wicket internals somehow ? 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 Configuration Setup To replace any of the _javascript_ files the user application may use: MyApplication#init(): public void init() { super.init(); IJavaScriptLibrarySettings jsSettings = getJavaScriptLibrarySettings(); jsSettings.setBackingLibraryReference(new DojoReference()); jsSettings.setWicketEventReference(new DojoWicketEventReference()); jsSettings.setWicketAjaxReference(new DojoWicketAjaxReference()); } Resource dependencies 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(new AnotherVersionOfJQueryReference()); AjaxRequestAttributes Each Ajax behavior and component can use o.a.w.ajax.attributes.AjaxRequestAttributes to configure how exactly the Ajax call should be executed and how its response should be handled. To do this use: AnyAjaxComponent/AnyAjaxBehavior.java: protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(AjaxRequestAttributes attributes); attributes.[set some attribute](); } The available attributes are: Name Description
[CONF] Apache Wicket Wicket Ajax
Wicket Ajax Page edited by Martin Grigorov Comment: Update docs for handlers' parameters Changes (8) ... Since Wicket Ajax now register DOM events (like click, change, ...) instead of using inline attributes like onclick, onchange, ... there is no more a script to decorate. Instead the new implementation provides points to listen to: - precondition - executed earlier. If it returns _false_ then the Ajax call (and all handlers below) is not executed at all - before handler - executed before the fire of the Ajax call - after handler - executed after the fire of the Ajax call but before it returns (if the Ajax call is asynchronous) - after handler - if the Ajax call is asynchronous then it is executed right after its firing. If it is synchronous then it is executed after the complete handler - success handler - executed on successful return of the Ajax call - failure handler - executed on unsuccessful return of the Ajax call ... } {code} There are also handy methods like _onBefore(CharSequence)_, _onComplete(CharSequence)_, ... but they do not provide access to the component which is bound with the Ajax behavior. An Ajax request can have 0 or more IAjaxCallListeners. ... - /ajax/call/complete Those replaces the old Wicket.Ajax.(registerPreCallHandler|registerPostCallHandler|registerFailureHandler) methods. Those replaces the old Wicket.Ajax.(registerPreCallHandler|registerPostCallHandler|registerFailureHandler) methods and uses publish/subscribe mechanism. Example (_javascript_): {code} Wicket.Event.subscribe(/ajax/call/failure, function(jqEvent, errorThrown, attributes, jqXHR, errorThrown, textStatus) { // do something when an Ajax call fails }); ... # To run the Ajax tests see the description at the top of _wicket-core/src/test/js/ajax.js_. It is required to run them through Web Server h4. What parameters are passed to the handlers ? # before handler - attributes (the Ajax call attributes), jqXHR (the jQuery XMLHttpRequest object), settings (the jQuery ajax settings) # after handler - attributes # success handler - attributes, jqXHR, data (the response), textStatus (the response status) # failure handler - attributes, errorMessage (the error message from jQuery) # complete handler - attrs, jqXHR, textStatus The global listeners receive the same parameters prepended by _jqEvent_. This is the event triggered by jQuery. See section *Global Ajax call listeners* above. Full Content What ? Why ? Design and implementation Table with renamed methods from the previous version Configuration Setup Resource dependencies AjaxRequestAttributes Migration steps o.a.w.ajax.IAjaxCallDecorator is replaced with o.a.w.ajax.attributes.IAjaxCallListener. Global Ajax call listeners Automatically migrated attributes. Tests for the client side Wicket Ajax functionality FAQ How to check whether my custom version of the backing _javascript_ library (jQuery) doesn't break Wicket internals somehow ? What parameters are passed to the handlers ? 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
[CONF] Apache Wicket Wicket Ajax
Wicket Ajax Page edited by Martin Grigorov Comment: Explain better the possible ajax request attributes Changes (19) ... The available attributes are: - method - the request method to use (GET or POST). Default: GET. - multipart - whether form submittion should use content type: multipart/form-data. Implies POST method. Default: false. || Name || Description || Default value || Short name || | method | the request method to use (GET or POST) | GET | m | | multipart | whether form submittion should use content type: multipart/form-data. Implies POST method | false | mp | - | event names - | a list of event names for which the Ajax call will be executed. For example: click, change, keyup, etc. Default: domready. etc.| domready | e | - form id - the id of the form which should be submitted with this Ajax call. Default: nothing. - submitting component name - the input name of the component which submits the form. Default: nothing. | form id | the id of the form which should be submitted with this Ajax call. | | f | | submitting component name | the input name of the component which submits the form. | | sc | - | data type - | what kind of data is expected in the response of the Ajax call (e.g. XML, JSON, HTML, JSONP). Default: xml. | xml | dt | - is | wicket ajax response - | a boolean flag which indicates whether the response is ajax-response which is handled by wicket-ajax.js or custom response type which can be handled by applications code (e.g. in IAjaxCallListeners success handler). Default: true. | true | wr | - preconditions - a list of _javascript_ function bodies which may abort the Ajax call. Return false from any precondition to abort the call. Default: the element is attached to the document. | preconditions | a list of _javascript_ function bodies which may abort the Ajax call. Return false from any precondition to abort the call. | checks that the element is attached to the document | pre | - | channel - | the name and type of the Ajax channel to use. Channels are used to queue the Ajax requests at the client side. See org.apache.wicket.ajax.AjaxChannel javadoc for more details. Default: | channel with name 0, and queue behavior. behavior | ch | - ajax call listeners - a list of listeners which are called at the most important points of the lifetime of the Ajax call. See below for more information. Default: empty list. | ajax call listeners | a list of listeners which are called at the most important points of the lifetime of the Ajax call. See below for more information. | empty list | bh, ah, sh, fh, ch | - | extra parameters - | a map of parameters which should be added to the query string/post data of the Ajax call. The name and value of such parameters should be known at the server side. Default: | empty map. map | ep | - dynamic extra parameters - parameters which values are calculated at the client side and added dynamically to the query string/post data of the Ajax call. Default: empty list. - request timeout - a timeout to abort the request if there is no response. Default: no timeout. | dynamic extra parameters | parameters which values are calculated at the client side and added dynamically to the query string/post data of the Ajax call. | empty list | dep | | request timeout | a timeout to abort the request if there is no response. | 0 (no timeout) | rt | - | allow default - | a boolean flag which indicates whether to allow the default behavior of the HTML element which listens for the event. For example: clicking on Ajax checkbox should allow the default behavior to actually check the box. Default: false. | false | ad | - async - a flag that indicates whether the Ajax call should be asynchronous or not. Default: true. - throttling settings - settings which define whether the Ajax call should be throttled and for how long. See the javadoc of org.apache.wicket.ajax.attributes.ThrottlingSettings for more information. Default: no throttling. | async | a boolean flag that indicates whether the Ajax call should be asynchronous or not. | true | async | | throttling settings | settings which define whether the Ajax call should be throttled and for how long. See the javadoc of org.apache.wicket.ajax.attributes.ThrottlingSettings for more information. | no throttling | tr | Attributes c (component id) and u (callback url) are automatically set by the Ajax behavior and they are not part of AjaxRequestAttributes. While constructing the _javascript_ that will register the event listener for that Ajax component/behavior these settings are
[CONF] Apache Wicket Wicket Ajax
Wicket Ajax Page added by Martin Grigorov 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 Wicket.Ajax.get Wicket.ajaxPost Wicket.Ajax.post Wicket.submitForm Wicket.Ajax.submitForm Wicket.submitFormById Wicket.Ajax.submitFormById 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(); // this is the reference to JQuery getAjaxSettings().setBackingLibraryReference(new _javascript_ResourceReference()); // wicket-event.js getAjaxSettings().setWicketEventReference(new _javascript_ResourceReference()); // wicket-ajax.js getAjaxSettings().setWicketAjaxReference(new _javascript_ResourceReference()); } This way the user application can upgrade/downgrade to new/old version of JQuery or even use YUI as backing library with the respective implementations of wicket-ajax and wicket-event based on YUI. Change Notification Preferences View Online | Add Comment
[CONF] Apache Wicket Wicket Ajax
Wicket Ajax Page added by Martin Grigorov 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(); // this is the reference to JQuery getAjaxSettings().setBackingLibraryReference(new _javascript_ResourceReference()); // wicket-event.js getAjaxSettings().setWicketEventReference(new _javascript_ResourceReference()); // wicket-ajax.js getAjaxSettings().setWicketAjaxReference(new _javascript_ResourceReference()); } This way the user application can upgrade/downgrade to new/old version of JQuery or even use YUI as backing library with the respective implementations of wicket-ajax and wicket-event based on YUI. Change Notification Preferences View Online | Add Comment
[CONF] Apache Wicket Wicket Ajax
Wicket Ajax Page added by Martin Grigorov 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 Wicket.Ajax.get Wicket.ajaxPost Wicket.Ajax.post Wicket.submitForm Wicket.Ajax.submitForm Wicket.submitFormById Wicket.Ajax.submitFormById 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(); // this is the reference to JQuery getAjaxSettings().setBackingLibraryReference(new _javascript_ResourceReference()); // wicket-event.js getAjaxSettings().setWicketEventReference(new _javascript_ResourceReference()); // wicket-ajax.js getAjaxSettings().setWicketAjaxReference(new _javascript_ResourceReference()); } This way the user application can upgrade/downgrade to new/old version of JQuery or even use YUI as backing library with the respective implementations of wicket-ajax and wicket-event based on YUI. Change Notification Preferences View Online | Add Comment
[CONF] Apache Wicket Wicket Ajax rewriting
Wicket Ajax rewriting Page edited by Pedro Santos Changes (0) ... Full Content I'm in process of rewriting the Ajax support. The current (very experimental) code is available at http://svn.apache.org/repos/asf/wicket/sandbox/knopp/experimental in package org.apache.wicket.ajaxng (will be later renamed to ajax replacing current ajax classes). Some of the improvements over current Ajax implementation. Should be much more stable and solid than current implementation. It supports timeout for the Ajax request and timeout for the processing afterwards. The new ajax pipeline should never hang with "chanel busy. postponing" like to current one can. Much smaller impact on generated markup file. Current ajax generates markup such as code-keyword">var wcall=wicketAjaxGet('../?wicket:interface=:2:c1::IBehaviorListener:1:1',null,null, function() {return Wicket.$('c12') != null;}.bind(this)); while for the same effect new Ajax implementation only generates W.e('click',{c:"c12",b:0}); The call is no longer part of actual element, rather than that it's executed as onDomReady _javascript_ Adding custom before/after handlers, preconditions and parameters no longer needs ugly string concatenations Improved throttling TextField/TextArea selection and cursor position is preserved when the element is refreshed with Ajax AjaxRequestTarget allows to register _javascript_ executed right before and right after component replacement. The _javascript_ is asynchronous and the rest of the pipeline waits until the _javascript_ calls the notify method (can be used for animations). Also the actual replacement call can be customized. AjaxRequestTarget also allows prepend and append _javascript_s to be asynchronous. Usage of new API AjaxRequestAttributes defines possible configuration options for AjaxRequest. Example of creating Ajax link that displays an confirmation window: add(new AjaxLink("link") { protected void updateAttributes(AjaxRequestAttributes attributes) { super.updateAttributes(attributes); attributes.getPreconditions() .add("function(requestQueueItem) { return confirm('Really?'); }"); } public void onClick(AjaxRequestTarget target) { ... } } Note: Asynchronous preconditions are also supported, see AjaxRequestAttributes#getPreconditions. Example of Ajax link with custom URL parameters. add(new AjaxLink("link") { protected void updateAttributes(AjaxRequestAttributes attributes) { super.updateAttributes(attributes); attributes.getUrlArguments().put("param1", "value1"); } public void onClick(AjaxRequestTarget target) { ... } } Example of Ajax link with URL parameters added dynamically from _javascript_. add(new AjaxLink("link") { protected void updateAttributes(AjaxRequestAttributes attributes) { super.updateAttributes(attributes); attributes.getUrlArgumentMethods() .add("function(requestQueueItem) { return { x:4, y:someJavascriptExpression() }; }"); } public void onClick(AjaxRequestTarget target) { ... } } Change Notification Preferences View Online | View Changes | Add Comment