Key Press Behavior

Attaches any of the predefined JSF Widget Library (JWL) actions and/or user-supplied JavaScriptâ„¢ to the pressing of a control or function key. The behavior can be applied to the entire page (pressing the key anywhere in the page invokes the behavior) or it can be scoped to apply to a single tag (for example, a single input field) or tags within a container (for example, tags within a div). Used instead of <hx:behavior> so that you do not need to write the JavaScript that determines which key was pressed (somewhat complicated code to write cross-browser). Replaces <hx:inputHelperKeybind> which is now deprecated.

 

Rendering

This component has no visual rendering. No HTML is rendered.

 

Quick Edit view

Configure this component using the Quick Edit view. To open the Quick Edit view, click

Window | Show View | Quick Edit.

The common attributes for the <hx:behaviorKeyPress> component are listed in the table below.

Table 1. Key Press Behavior attributes

Attribute name

Description

behaviorAction

The name of the action(s) to be run. If more than one action name is provided they should be separated with a semicolon.

binding

An expression that binds the component's instance (usually a user interface component) to a bean property (usually in the backing file).

event

The name of the event to which the behavior is attached. For example "onclick". It must include the "on" prefix.

id

Assigns a name to a component. Should be a unique name within a JSP.

key

Specifies a key expression.

onActionFunction

A JavaScript function to be executed. The function is executed before the action is executed. If the function returns false, the action is not run and processing of the event is halted.

rendered

Can be set to true or false:

  • false - Component will not be rendered to the browser at runtime.

  • true - Component will get rendered. This is the default value.

target

The ID of the component to which the behavior is attached. If it is not set then the parent component is the default target.

Note: The ID can also identify an HTML (non-JSF) tag. For example, to apply the behavior to the entire page, set the target attribute to #body.

targetAction

The target(s) of the action(s) to be run. By default, the action's target is the tag the behavior is assigned to (as a child or via target). If more than one action is provided, more than one target may be provided (separated by semicolons).