Actions

JSF Behaviors usually take actions as one of their attributes. An action is an easy way of performing a common JavaScriptâ„¢ task such as disabling a field.

An action has an optional target (specified as a separate attribute). The target is what the action "works on", e.g., it identifies the field which should be disabled.

A sequence of actions can be performed by specifying more than one action as an attribute value, with the actions separated by semicolons. Multiple targets can be specified using the same syntax. Targets are sequentially paired with the actions (so the number of targets and actions should be the same.

For example, the following attributes specify that one field should be disabled while another field should be enabled:

Actions return either true or false. If an action returns false, processing of the list of actions is halted. Some actions always return false (thus must be the last action in the list (e.g., actions that set focus), some actions are conditional (return true or false depending on what happens in the action) and thus can be used to conditionally execute a sequence of actions.

"action:UNLOCKED;LOCKED", "target:form1:text2;form1:text3"

If an action returns true but you want to stop the underlying event which triggered it (e.g., you are coding an onclick event and assigning it a generic behavior that does a HIDE action), follow the action with a "NOTHING" action (it always returns false). For example:

<hx:behavior event="onclick" behaviorAction="hide;nothing" actionTarget="div1" />

 

List of JWL actions

Table 1. List of JWL actions

Action

Target

Result

Description

GOTO

url('value')

true

Goes to the specified page. Note the syntax of the target.

GET

id

true

Invokes the Ajax behavior associated with the tag identified by the id.

WHILEEVENT

milliseconds

true

For use with actions attached to events that have an "inverse", notably onmousedown and onkeydown. The action pauses for specified milliseconds, then before executing each remaining action in the list of actions, it checks to see if the inverse event has occurred and if it has, execution of the action is halted. It is used primarily when doing an Ajax call followed by some actions tied to an onmousedown event. This will stop the processing (stop the Ajax call, stop showing the results of an Ajax call) if the mouse has moved outside of the tag to which the event is attached.

LOCKED

id

true

Disable the specified tag. Disables all tags within the tag if it is a container (for example, a div).Disable the specified tag. Disables all tags within the tag if it is a container (for example, a div).

UNLOCKED

id

true

Enable the specified tag. Enables all tags within the tag if it is a container (for example, a div).

INVERTLOCKED

id

true

Inverts the disabled state of the specified tag. Sets all tags within the tag to the same state if the tag is a container.

SHOW

id

true

Shows the specified tag.

HIDE

id

true

Hides the specified tag.

INVERTHIDE

id

true

Inverts the display of the specified tag.

VISIBLE

id

true

Makes the specified tag visible.

INVISIBLE

id

true

Makes the specified tag invisible.

Note: When a tag is hidden, it cannot be seen and it occupies no space. When a tag is invisible, it cannot be seen but it occupies space (that is, the tag is there, it's just that none of it's pixels are drawing.

INVERTVISIBLE

id

true

Inverts the visibility of the specified tag.

NEXTTAB

id

true

Advance to the next control in the tab order relative to the specified ID.

NEXTTABCLEAR

id

true

Clear (delete) characters in the field from the cursor position to the end of the field, and then advance to the next control in the tab order relative to the specified ID.

PREVTAB

id

true

Advance to the previous control in the tab order relative to the specified ID.

PREVTABCLEAR

id

true

Clear (delete) characters in the field from the cursor position to the end of the field, and then advance to the previous control in the tab order relative to the specified ID.

CLICK

id

false

"click" the control identified by the specified ID.

SUBMIT

id

false

Submit a form using the specified ID. The ID can be any field in the form or of the form itself. If the ID identifies a submit button, that button is used to submit the form. If the ID identifies any other tag in the form or the form itself, the first submit button in the form is used to do the submit. The submit is done using the submit button (i.e., not doing a form.submit()) so that the onsubmit handler for the form will fire.

FOCUS

id

false

Sets focus to the specified tag. The content of the field receiving focus may/may not be selected depending on the browser.

SELECTED

id

false

Sets focus to the specified tag and selects the content.

UNSELECTED

id

false

Sets focus to the specified tag and unselects the content.

ALERT

string

false

Display an alert message box with the specified string as the message. If the target is set to the special string @ERROR, the (localized) error message in the event object is displayed as the message.

CONFIRM

string

true if OK else false

Display a "confirm" (ok cancel) message box with the specified string as the message. If the target is set to the special string @ERROR, the (localized) error message in the event object is displayed as the message.

PADLEFT

id

true

Deprecated. Pads the value of the field identified by the ID with spaces to its maximum length. Padding is done on the left.

PADRIGHT

id

true

Deprecated. Pads the value of the field identified by the ID with spaces to its maximum length. Padding is done on the right.

TRIM

id

true

Deprecated. Removes spaces from the left and right of the field identified by the ID.

NOTHING

none

false

Do nothing (useful with keybind and mousebind as a way of "no-oping" a keystroke or mouseclick).

Note: