AJAX submit behavior

Replaces the content of a "panel" tag in the page with content from the original page. The content is retrieved using an AJAX post (sub) request so that the entire page is not redrawn when the additional content is retrieved. The values of the form that contains the panel are submitted to the server as part of the request.

JSF tags that emit the component

<hx:ajaxRefreshSubmit>

Base HTML

Invoked only from a JWL GET action which is part of a behavior (for example, a generic behavior) attached to any HTML tag that supports event handlers. The target of the GET must be the ID of the panel that contains (or is the target of) this behavior.

JavaScript constructor

hX_5.addBehavior("id", "onget", new hX_5.JSFBehaviorAjaxSubmit(attributes)); where

id

The ID of the HTML tag to which the component is attached.

attributes

Comma separated list of attributes where each attribute is a quoted string consisting of the attribute name and value separated by a colon, for example "label:MyLabel".

Supported events

Event

Description

onget

Note the use of the special event name. This is required.

Attributes

Table 1.

Attribute name

Description

title

While a request is in progress, the title is assigned to the panel's primary tag (for example, a div) and to the "temporary tabstop" assigned to the panel. This shows as both a tooltip if you mouse over the panel and is available to screen readers.

progress-actions

While the request is in progress, the JWL action(s) to apply to the panel. Currently the only supported action is LOCKED.

on-start

Before the request is sent, this JavaScriptâ„¢ function is executed. It has no arguments. If it returns false execution is halted. This function can be used (in conjunction with oncomplete to customize what is displayed while the request is in progress.

on-error

If a request fails/times out, this JavaScript is executed. The signature is (thisObj, thisError) where thisObj points to the panel and thisError is a string that describes the error.

on-complete

If a request succeeds, after the content of the panel is replaced, this JavaScript is executed. The function has no meaningful arguments.

on-start

Before the request is sent, this JavaScript function is executed. It has no arguments. If it returns false execution is halted. This function can be used (in conjunction with oncomplete to customize what is displayed while the request is in progress.

Sequencing

Runs when the "GET" is issued. Does not stop the event (a "STOP" action should be encoded in the originating behavior).

API calls

Table 2. API calls

API call

Description

object = setAttribute(attribute)

Sets an attribute or changes its value (if it was set previously).

string = getAttribute(attribute-name)

Retrieves the current value of an attribute.

Example code

Add AJAX retrieval to a panel with the ID "form1:panelHelp". The contents of the form that contains the panel is submitted to the server when the request is made.

hX.addBehavior("form1:panelHelp", "onget", new hX.JSFBehaviorAjaxSubmit("on-error:return doError(this, event);", "on-start:return doPrep(this, event);"));

Feedback