The DOM element that triggered this Ajax request, or an id string of the element to use as the triggering element.
Optionalevent: EventThe DOM event that triggered this Ajax request. The
event argument is optional.
Optionaloptions: {The set of available options that can be sent as request parameters to control client and/or server side request processing. Acceptable name/value pair options are:
| name | value |
|---|---|
execute |
space seperated list of client identifiers |
render |
space seperated list of client identifiers |
onevent |
function to callback for event |
onerror |
function to callback for error |
params |
object containing parameters to include in the request |
delay |
If less than delay milliseconds elapses
between calls to request() only the most recent
one is sent and all other requests are discarded. If the
value of delay is the literal string
'none' without the quotes, or no delay is
specified, no delay is used. |
resetValues |
If true, ensure a post data argument with the name
jakarta.faces.partial.resetValues and the value true is
sent in addition to the other post data arguments. This
will cause UIViewRoot.resetValues() to be called, passing
the value of the "render" attribute. Note: do not use any
of the @ keywords such as @form or @this with this option
because UIViewRoot.resetValues() does not descend into
the children of the listed components. |
options argument is optional.
Send an asynchronous Ajax request to the server.
Usage:
Example showing all optional arguments:Implementation Requirements:
This function must:- Be used within the context of a
- Capture the element that triggered this Ajax request
(from the
- If the
- If the
- If the
- If the DOM element could not be determined, throw an error.
- If the
- If the ID of the
- If the
- Determine the
- Get the
- Collect post data arguments for the Ajax request.
- The following name/value pairs are required post data arguments:
name
value
Contents of
The identifier of the element that triggered this request.
Call
- Collect optional post data arguments for the Ajax request.
- Determine additional arguments (if any) from the
- If the keyword
- If the keyword
- Otherwise, there are specific identifiers that need to be sent. Create the post
data argument with the name
- If
- If
- If the keyword
- If the keyword
- Otherwise, there are specific identifiers that need to be sent. Create the post
data argument with the name
- If
- If
- If
- Determine additional arguments (if any) from the
- Encode the set of post data arguments.
If the
- Join the encoded view state with the encoded set of post data arguments
to form the
- Create a request
- Send a
- Set the request header with the name:
- Determine the
-
Form serialization should occur just before the request is sent to minimize the amount of time between the creation of the serialized form data and the sending of the serialized form data (in the case of long requests in the queue). Before the request is sent it must be put into a queue to ensure requests are sent in the same order as when they were initiated. The request callback function must examine the queue and determine the next request to be sent. The behavior of the request callback function must be as follows:form, else throw an error.sourceargument, also known as thesourceelement.sourceelement isnullorundefinedthrow an error.sourceargument is not astringor DOM element object, throw an error.sourceargument is astring, find the DOM element for thatstringidentifier.jakarta.faces.ViewStateelement could not be found, throw an error.jakarta.faces.ViewStateelement has a<VIEW_ROOT_CONTAINER_CLIENT_ID><SEP>prefix, where <SEP> is the currently configuredUINamingContainer.getSeparatorChar()and <VIEW_ROOT_CONTAINER_CLIENT_ID> is the return fromUIViewRoot.getContainerClientId()on the view from whence this state originated, then remember it as namespace prefix. This is needed during encoding of the set of post data arguments.onerrorandoneventarguments are set, they must be functions, or throw an error.sourceelement'sformelement.formview state by callingfaces.getViewStatepassing theformelement as the argument.jakarta.faces.ViewStatejakarta.faces.ViewStatehidden field.This is included whenfaces.getViewStateis used.jakarta.faces.partial.ajaxtruejakarta.faces.sourcejakarta.faces.ClientWindowfaces.getClientWindow, passing the current form. If the return is non-null, it must be set as the value of this name/value pair, otherwise, a name/value pair for client window must not be sent.optionsargument. Ifoptions.executeexists:@noneis present, do not create and send the post data argumentjakarta.faces.partial.execute.@allis present, create the post data argument with the namejakarta.faces.partial.executeand the value@all.jakarta.faces.partial.executeand the value as a space delimitedstringof client identifiers.options.executedoes not exist, create the post data argument with the namejakarta.faces.partial.executeand the value as the identifier of the element that caused this request.options.renderexists:@noneis present, do not create and send the post data argumentjakarta.faces.partial.render.@allis present, create the post data argument with the namejakarta.faces.partial.renderand the value@all.jakarta.faces.partial.renderand the value as a space delimitedstringof client identifiers.options.renderdoes not exist do not create and send the post data argumentjakarta.faces.partial.render.options.delayexists let it be the value delay, for this discussion. Ifoptions.delaydoes not exist, or is the literal string'none', without the quotes, no delay is used. If less than delay milliseconds elapses between calls to request() only the most recent one is sent and all other requests are discarded.options.resetValuesexists and its value istrue, ensure a post data argument with the namejakarta.faces.partial.resetValuesand the valuetrueis sent in addition to the other post data arguments. This will causeUIViewRoot.resetValues()to be called, passing the value of the "render" attribute. Note: do not use any of the@keywords such as@formor@thiswith this option becauseUIViewRoot.resetValues()does not descend into the children of the listed components.eventargument. The following name/value pairs may be used from theeventobject:target- the ID of the element that triggered the event.captured- the ID of the element that captured the event.type- the type of event (ex: onkeypress)alt-trueif ALT key was pressed.ctrl-trueif CTRL key was pressed.shift-trueif SHIFT key was pressed.meta-trueif META key was pressed.right-trueif right mouse button was pressed.left-trueif left mouse button was pressed.keycode- the key code.jakarta.faces.ViewStateelement has a namespace prefix, then make sure that all post data arguments are prefixed with this namespace prefix.query stringthat will be sent to the server.contextobject and set the properties:
The request context will be used during error/event handling.source(the source DOM element for this request)onerror(the error handler for this request)onevent(the event handler for this request)beginevent following the procedure as outlined in the Jakarta Faces Specification Document section 13.3.5.3 "Sending Events".Faces-Requestand the value:partial/ajax.posting URLas follows: If the hidden fieldjakarta.faces.encodedURLis present in the submitting form, use its value as theposting URL. Otherwise, use theactionproperty of theformelement as theURL.Determine whether or not the submitting form is using
multipart/form-dataas itsenctypeattribute. If not, send the request as anasynchronous POSTusing theposting URLthat was determined in the previous step. Otherwise, send the request using a multi-part capable transport layer, such as a hidden inline frame. Note that using a hidden inline frame does not useXMLHttpRequest, but the request must be sent with all the parameters that a FacesXMLHttpRequestwould have been sent with. In this way, the server side processing of the request will be identical whether or the request is multipart or not.The
begin,complete, andsuccessevents must be emulated when using the multipart transport. This allows any listeners to behave uniformly regardless of the multipart orXMLHttpRequestnature of the transport.faces.ajax.responsepassing therequestobject.complete(readyState 4), dequeue the request (remove it from the queue). If the request has not been sent (readyState 0), send the request. Requests that are taken off the queue and sent should not be put back on the queue.