Interface ClientBehavior
-
- All Superinterfaces:
Behavior
- All Known Implementing Classes:
AjaxBehavior,ClientBehaviorBase
public interface ClientBehavior extends Behavior
ClientBehavior is the base contract for
Behaviors that attach script content to client-side events exposed byClientBehaviorHoldercomponents. Instances ofClientBehaviormay be attached to components that implement theClientBehaviorHoldercontract by callingClientBehaviorHolder.addClientBehavior(java.lang.String, jakarta.faces.component.behavior.ClientBehavior). Once aClientBehaviorhas been attached to aClientBehaviorHoldercomponent, the component callsgetScript(jakarta.faces.component.behavior.ClientBehaviorContext)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 theResourceDependencyorResourceDependenciesannotation.- Since:
- 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddecode(FacesContext context, UIComponent component)Decode any new state of thisClientBehaviorfrom the request contained in the specifiedFacesContext.Set<ClientBehaviorHint>getHints()Returns hints that describe the behavior of the ClientBehavior implementation.StringgetScript(ClientBehaviorContext behaviorContext)Return the script that implements this ClientBehavior's client-side logic.
-
-
-
Method Detail
-
getScript
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- theClientBehaviorContextthat 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:
- script that provides the client-side behavior, or null if no script is required.
- Throws:
NullPointerException- ifbehaviorContextisnull- Since:
- 2.0
-
decode
void decode(FacesContext context, UIComponent component)
Decode any new state of this
ClientBehaviorfrom the request contained in the specifiedFacesContext.During decoding, events may be enqueued for later processing (by event listeners who have registered an interest), by calling
queueEvent(). Default implementation delegates decoding toClientBehaviorRenderer.decode(FacesContext, UIComponent, ClientBehavior)- Parameters:
context-FacesContextfor the request we are processingcomponent-UIComponentthe component associated with thisBehavior- Throws:
NullPointerException- ifcontextorcomponentisnull.- Since:
- 2.0
-
getHints
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.SUBMITTINGis present, the Renderer may choose to alternate the scripts that it generates itself.- Returns:
- a non-null, unmodifiable collection of ClientBehaviorHints.
- Since:
- 2.0
-
-