JBoss.orgCommunity Documentation
Read this chapter for details on special functions for use with particular components. Using JavaServer Faces Expression Language (JSF EL), these functions can be accessed through the data
attribute of components. Refer to Section 2.4.4.1, “data” for details on the data
attribute.
The <rich:componentControl>
behavior allows JavaScript API functions to be called on target components. The functions are called after defined events are triggered on the component to with the <rich:componentControl>
behavior is attached. Initialization variants and activation events can be customized, and parameters can be passed to the target component.
The operation
attribute is required to attach JavaScript functions to the parent component, along with either the target
or selector
attributes. Use the operation
attribute to specify the JavaScript API function to perform. Use the target
attribute to define the id
identifier of the target component, or use the selector
attribute to define a number of target components through the use of valid jQuery selectors.
Use the event
attribute to specify the event that triggers the JavaScript API function call if it is different from the default triggering event for the parent component.
Example 15.1. <rich:componentControl>
basic usage
<h:commandButton value="Show Modal Panel">
<!--componentControl is attached to the commandButton-->
<rich:componentControl target="ccModalPanelID" event="click" operation="show"/>
</h:commandButton>
The example contains a single command button, which when clicked shows the modal panel with the identifier ccModalPanelID
.
The rich:clientId('id')
function returns the client identifier related to the passed component identifier ('id'
). If the specified component identifier is not found, null
is returned instead.
The rich:component('id')
function is a shortcut for the equivalent #{rich:clientId('id')}.component
code. It returns the UIComponent instance from the client, based on the passed server-side component identifier ('id'
). If the specified component identifier is not found, null
is returned instead.
The rich:element('id')
function is a shortcut for the equivalent document.getElementById(#{rich:clientId('id')})
code. It returns the element from the client, based on the passed server-side component identifier. If the specified component identifier is not found, null
is returned instead.
The rich:findComponent('id')
function returns the a UIComponent instance of the passed component identifier. If the specified component identifier is not found, null
is returned instead.
Example 15.3. rich:findComponent
example
<h:inputText id="myInput">
<a4j:support event="keyup" render="outtext"/>
</h:inputText>
<h:outputText id="outtext" value="#{rich:findComponent('myInput').value}" />
The rich:isUserInRole(Object)
function checks whether the logged-in user belongs to a certain user role, such as being an administrator. User roles are defined in the web.xml
settings file.
Example 15.4. rich:isUserInRole
example
The rich:isUserInRole(Object)
function can be used in conjunction with the rendered
attribute of a component to only display certain controls to authorized users.
<rich:editor value="#{bean.text}" rendered="#{rich:isUserInRole('admin')}"/>