Top Description Methods
jakarta.faces.component.behavior

public Interface ClientBehavior

extends Behavior
Known Direct Implementers
jakarta.faces.component.behavior.ClientBehaviorBase
Imports
java.util.Set, jakarta.faces.component.UIComponent, jakarta.faces.context.FacesContext

ClientBehavior is the base contract for Behaviors that attach script content to client-side events exposed by ClientBehaviorHolder components. Instances of ClientBehavior may be attached to components that implement the ClientBehaviorHolder contract by calling ClientBehaviorHolder#addClientBehavior. Once a ClientBehavior has been attached to a ClientBehaviorHolder component, the component calls getScript to obtain the behavior's script and the component wires this up to the appropriate client-side event handler. Note that the script content returned by this method is always in-line script content. If the implementing class wants to invoke functions defined in other script resources, the implementing class must use the jakarta.faces.application.ResourceDependency or jakarta.faces.application.ResourceDependencies annotation.

Since
2.0

Method Summary

Modifier and TypeMethod and Description
public void
decode(FacesContext
FacesContext for the request we are processing
context
,
UIComponent
UIComponent the component associated with this Behavior
component
)

Decode any new state of this ClientBehavior from the request contained in the specified FacesContext.

public Set<ClientBehaviorHint>

Returns:

a non-null, unmodifiable collection of ClientBehaviorHints.
getHints
()

Returns hints that describe the behavior of the ClientBehavior implementation.

public String

Returns:

script that provides the client-side behavior, or null if no script is required.
getScript
(ClientBehaviorContext
the ClientBehaviorContext that provides properties that might influence this getScript() call. Note that ClientBehaviorContext instances are short-lived objects that are only valid for the duration of the call to getScript(). ClientBehavior implementations must not hold onto references to ClientBehaviorContexts.
behaviorContext
)

Return the script that implements this ClientBehavior's client-side logic.

Inherited from jakarta.faces.component.behavior.Behavior:
broadcast

Method Detail

decodeback to summary
public void decode(FacesContext context, UIComponent component)

Decode any new state of this ClientBehavior from the request contained in the specified FacesContext.

During decoding, events may be enqueued for later processing (by event listeners who have registered an interest), by calling queueEvent(). Default implementation delegates decoding to jakarta.faces.render.ClientBehaviorRenderer#decode(FacesContext, UIComponent, ClientBehavior)

Parameters
context:FacesContext

FacesContext for the request we are processing

component:UIComponent

UIComponent the component associated with this Behavior

Exceptions
NullPointerException:
if context or component is null.
Since
2.0
getHintsback to summary
public Set<ClientBehaviorHint> getHints()

Returns hints that describe the behavior of the ClientBehavior implementation. The hints may impact how Renderers behave in the presence of Behaviors. For example, when a Behavior that specifies ClientBehaviorHint.SUBMITTING is present, the Renderer may choose to alternate the scripts that it generates itself.

Returns:Set<ClientBehaviorHint>

a non-null, unmodifiable collection of ClientBehaviorHints.

Since
2.0
getScriptback to summary
public String getScript(ClientBehaviorContext behaviorContext)

Return the script that implements this ClientBehavior's client-side logic.

ClientBehavior.getScript() implementations are allowed to return null to indicate that no script is required for this particular getScript() call. For example, a ClientBehavior implementation may return null if the Behavior is disabled.

Parameters
behaviorContext:ClientBehaviorContext

the ClientBehaviorContext that provides properties that might influence this getScript() call. Note that ClientBehaviorContext instances are short-lived objects that are only valid for the duration of the call to getScript(). ClientBehavior implementations must not hold onto references to ClientBehaviorContexts.

Returns:String

script that provides the client-side behavior, or null if no script is required.

Exceptions
NullPointerException:
if behaviorContext is null
Since
2.0