When a behavior is invoked, it runs one or more JWL Actions along with any provided Javascript. A JWL Action is a predefined block of Javascript such as "disable a field", "hide a field", "show an alert box". In addition, some behaviors (notably ones that deal with validation) can also toggle which CSS classes are associated with a field (as well as executing functions and actions).
JWL Behaviors add to an object's event handler as opposed to replacing it. For example, you can attach a JavaScriptâ„¢ function to the onblur handler of an object and then attach a behavior to the onblur function as well. Both the event handler and the behavior are run when the event is fired.
If a behavior can execute a user-supplied Javascript function, the function is executed before any JWL Actions. If the function returns false, the actions are not executed. Similarly, if the function returns false, any CSS styles are not applied. Actions behave similarly -- if an action returns false, any additional actions are not performed.
If a Javascript event handler is provided in addition to the behavior (for example, script is attached to an onblur event handler and a behavior is attached to the same onblur event handler), the supplied JavaScript will either be executed first or last depending on the event. If the JavaScript event handler runs first and it returns false, the behavior will not be run.
The available behavior tags are:
Components that are initially hidden on the palette are denoted by an asterisk (*) next to their name in the tables.
Component | Tag Name | Description |
---|---|---|
Generic Behavior | <hx:behavior> | Assign a JWL Action and/or JavaScript to a DOM event handler. |
Key Press Behavior | <hx:behaviorKeyPress> | Assign a JWL Action and/or JavaScript to the pressing of a function/control key when a component or the content of a component has focus. |
Right Mouse Click Behavior | <hx:behaviorRightMouse> | Assign a JWL Action and/or Javascript to the clicking of the right mouse button on a component or on the content of a component. |
Input Assist Behavior | <hx:inputHelperAssist> | Assign client-side validation, input prompting, auto-tabbing, etc. to an inputText field. |
Field Tracking Behavior | <hx:inputHelperFormTracker> | Enable field/cursor tracking so that when a form is submitted, information about where the focus/cursor last was is transmitted as part of the submit. This tag is primarily for use in iSeries-based applications. |
Key Bind Behavior | <hx:inputHelperKeybind> | Now deprecated. Replaced by hx:behaviorKeyPress. |
Set Initial Focus Behavior | <hx:inputHelperSetFocus> | When a page loads, set initial focus to a control in the page. |
Typehead Complete Component | <hx:inputHelperTypeahead> | Assign type-ahead support (auto-suggest or auto-complete) to an inputText field. |