I helped implement one of the numerous AJAX JSF approaches for years (the fry:ajax tag from J4Fry) and during the last months this approach was integrated into Apache MyFaces 2.0 while adapting it's interfaces to the new spec. The spec covers a lot of the basic features in a generic and flexible way. Btw.: MyFaces 2.0 is on its way, we're currently gluing everything together and I'm hoping for an alpha by end of august.
The most basic part of an AJAX implementation is replacing parts of the document. These are the features the JSF 2.0 API provides:
- execute - The components that will be processed on the server in a blank separated list. Only the components named within this parameter get their decode, validate and updateModel methods called during phase 2-4. There is an @all keyword you can use to process the entire component tree.
- render - The components that will be rendered and replaced within the HTML page in a blank separated list.
- onevent - A JS callback that is triggered with three different events:
- begin - occurs immediately before the request is sent
- complete - occurs after the AJAX request has completed but before DOM manipulation has taken place
- success - occurs after DOM manipulation has taken place (only for successfull request, else see onerror)
- begin - occurs immediately before the request is sent
- onerror - A JS callback that is triggered when the server signalizes that an error has occured.
- params - An object that may include additional parameters to include in the request.
f:ajax provides three more attributes that offer JSF specific enhancements:
- disabled - Indicates whether the AJAX behavior script should not be rendered.
- listener - A method binding to execute when the AJAX request is processed on the server.
- immediate - same as the attribute you know from the standard JSF action sources.
- timout - How long to wait for the HTTP response before aborting the request.
- delay - How long to wait before issuing a request (helpfull with onkeyup or mouse move events to avoid tons of requests).
- queuesize - Number of requests to queue (discard the oldest when the queue is full and a new one arrives).
- partial submit - The current spec requires submission of the entire form though only the elements named in the execute parameter are being processed. Setting partial submit (or pps) to true could reduce the submit volume to the actually processed values.
- disable - HTML id's of the components to disable while the request is running (can be implemented via onevent).
- loadingbar - HTML id of an img tag to make visible while the request is running (can also be implemented via onevent).
- errorhandling for errors that occur within the javascript - can be done with the onerror parameter, but the spec doesn't mention this use.
No comments:
Post a Comment