Chapter 6. The RichFaces Components

The library encompasses ready-made components built based on the Rich Faces CDK.

6.1.  < a4j:ajaxListener >

The <a4j:ajaxListener> component is the same one as "ActionListener" or "ValueChangeListener" , but for an Ajax container.

Table 6.1. a4j : ajaxListener attributes

Attribute NameDescription
type Fully qualified Java class name of an AjaxListener to be created and registered.

Table 6.2. Component identification parameters

NameValue
listener-classorg.ajax4jsf.framework.ajax.AjaxListener
event-classorg.ajax4jsf.framework.ajax.AjaxEvent
tag-classorg.ajax4jsf.taglib.html.jsp.AjaxListenerTag

6.1.1. Creating on a page

Simple Component definition on a page:

Example:


...
    <a4j:ajaxListener type="demo.Bean"/>
...

6.1.2. Dynamical creation of a component from Java code

Example:


package demo;
      
public class ImplBean implements import org.ajax4jsf.component.html.AjaxListener{
    ...
}


import demo.ImplBean;
...
ImplBean myListener = new ImplBean();
...

6.1.3. Key attributes and ways of usage

Additional to the listeners provided by JSF specification, RichFaces add one more: Ajax Listener ( <a4j:ajaxListener> ). Ajax Listener is invoked before the Render Response phase. Instead of Action Listener of Value Change Listener which are not invoked when Validation of Update Model phases failed, Ajax Listener is guarantied to be invoked for each Ajax response. Thus, it is a good place for update the list of re-rendered components, for example. Ajax Listener is not invoked for non-Ajax request and when RichFaces works in "Ajax Request generates Non-Ajax Response" mode. Therefore, Ajax Listener invocation is a good indicator that Ajax response is going to be processed. Attribute "type" defines the fully qualified Java class name for listener. This class should implement org.ajax4jsf.framework.ajax.AjaxListener interface. You can access to the source of the event (Ajax component) using event.getSource() call.

Example:


...
    <a4j:commandLink id="cLink" value="Click it To Send Ajax Request">
        <a4j:ajaxListener type="demo.Bean"/>
    </a4j:commandLink>
...

Example:


package demo;

import org.ajax4jsf.framework.ajax.AjaxEvent;

public class Bean implements org.ajax4jsf.framework.ajax.AjaxListener{
... 
    public void processAjax(AjaxEvent arg0){
        //Custom Developer Code 
    }
...
}

6.1.5. Relevant resources links

Some additional information about usage of component can be found here.

6.2.  < a4j:keepAlive >

The <a4j:keepAlive> component allows to keep a state of each bean between requests.

Table 6.3. a4j : keepAlive attributes

Attribute NameDescription
ajaxOnly if true, bean value restored in ajax requests only.
beanName name of bean for EL-expressions.

Table 6.4. Component identification parameters

NameValue
component-typeorg.ajax4jsf.components.KeepAlive
component-familyorg.ajax4jsf.components.AjaxKeepAlive
component-classorg.ajax4jsf.components.AjaxKeepAlive

6.2.1. Creating on a page

Simple Component definition on a page:

Example:


<a4j:keepAlive beanName = "#{myClass.testBean}"/>

6.2.2. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.ajax.AjaxKeepAlive;
...
AjaxKeepAlive myKeepAlive = new AjaxKeepAlive();
...
        

6.2.3. Key attributes and ways of usage

If a managed bean is declared with 'request' scope in the configuration file with the help of 'managed-bean-scope' tag then the life-time of this bean instance is valid only for the current request. Any attempts to make a reference to the bean instance after the request end will throw in Illegal Argument Exception by the server. To avoid these kinds of Exception, component <a4j:keepAlive> is used to maintain the state of the whole bean object among subsequent request.

Example:


<a4j:keepAlive beanName = "#{myClass.testBean}"/>

Note that the attribute 'beanName' must point to a legal jsf EL expression which resolves to a managed mean instance. For example for the above code the class definition may look like this:



        class MyClass{
    ...
    private TestBean testBean;
    // Getters and Setters for testBean.
    ...
}
    

6.2.4. Relevant resources links

Here you can see the example of <a4j:keepAlive> usage and sources for the given example.

Some additional information about usage of component can be found here.

6.3.  < a4j:jsFunction >

6.3.1. Description

The <a4j:jsFunction> component allows to invoke the server side data and return it in a JSON format to use in a client JavaScript calls.

Table 6.5. a4j : jsFunction attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression.
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
nameName of generated JavaScript function definition
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted

Table 6.6. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Function
component-familyorg.ajax4jsf.components.AjaxFunction
component-classorg.ajax4jsf.component.html.HtmlAjaxFunction
renderer-typeorg.ajax4jsf.components.AjaxFunctionRenderer

6.3.2. Creating on a page

Simple component definition example:

Example:


...
<head>
    <script>
        <!--There is some script named "myScript" that uses parameters which will be taken from server-->
    </script>
</head>
<body>
...
<a4j:jsFunction data="#{bean.someProperty}" name="callScript" oncomplete="myScript(data.subProperty1, data.subProperty2)"/>
...
    

The script "myScript" will be called after bean.someProperty data will be returned from server(e.g. It'll be object with two subproperties).

6.3.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.HtmlAjaxFunction;
...
HtmlAjaxFunction myFunction = new HtmlAjaxFunction();
...

6.3.4. Key attributes and ways of usage

As the component uses Ajax request to get data from server - it has all common Ajax Action attributes. Hence, "action" and "actionListener" can be invoked, and reRendering some parts of the page fired after calling function.

When using the <a4j:jsFunction> it's possible to initiate the Ajax request from the JavaScript and perform partial update of a page and/or invoke the JavaScript function with data returned by Ajax response.


...
<body onload="callScript()">
    ...
    <h:form>
    ...
    <a4j:jsFunction name="callScript" data="#{bean.someProperty1 }
                    "reRender="someComponent" oncomplete="myScript(data.subProperty1, data.subProperty2)">
        <a4j:actionparam name="param_name" assignTo="#{bean.someProperty2}">
        </a4j:actionparam>
    </a4j:jsFunction>
    ...
    </h:form>
    ...
</body>
...

The <a4j:jsFunction> allows to use <a4j:actionparam> or pure <f:param> for passing any number of parameters of the JavaScript function into Ajax request. <a4j:jsFunction> is similar to <a4j:commandButton> , but it could be activated from the JavaScript code. It allows to invoke some server side functionality and use the returned data in the JavaScript function invoked from "oncomplete" attribute. Hence it's possible to use <a4j:jsFunction> instead of <a4j:commandButton> . You can put it anywhere, just don't forget to use <h:form> ... </h:form> around it.

6.3.5. Relevant resources links

Here you can see the example of <a4j:jsFunction> usage and sources for the given example.

6.4.  < a4j:status >

6.4.1. Description

The <a4j:status> component generates elements for displaying of the current Ajax requests status. There are two status modes: Ajax request is in process or finished.

Table 6.7. a4j : status attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
forID of the AjaxContainer component whose status is indicated (in the format of a javax.faces.UIComopnent.findComponent() call).
forceIdIf true, render the ID of the component in HTML code without JSF modifications.
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
layoutDefine visual layout of panel, can be "block" or "inline".
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onstartJavaScript code, called on the start of a request.
onstopJavaScript code, called on the stop of a request.
renderedIf "false", this component is not rendered
startStyleCSS style class for the element displayed on the start of a request.
startStyleClassCSS style class for the element displayed on the start of a request.
startTextText for display on starting request.
stopStyleCSS style for element displayed on request completion.
stopStyleClassCSS style class for element displayed on request
stopTextText for display on request complete.
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component

Table 6.8. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Status
component-familyjavax.faces.Panel
component-classorg.ajax4jsf.component.html.HtmlAjaxStatus
renderer-typeorg.ajax4jsf.components.AjaxStatusRenderer


6.4.2. Creating on a page

There are two ways to define elements indicating a request status :

  • With "StartText"/"StopText" atributes:
    
    <a4j:status startText="Progress" stopText="Done" for="stat1">

    In this case, text elements for the corresponding status are generated.

  • With "Start"/"Stop" facets definition:
    
    <a4j:status for="stat2">
        <f:facet name="start">
            <h:graphicImage value="ajax_process.gif" />
        </f:facet>
        <f:facet name="stop">
            <h:graphicImage value="ajax_stoped.gif" />
        </f:facet>
    </a4j:status>

    In this case, the elements are generated for each status and correspond the facets content.

6.4.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.HtmlAjaxStatus;
...
HtmlAjaxStatus  myStatus = new HtmlAjaxStatus();
...

6.4.4. Key attributes and ways of usage

There are two ways for the components or containers definition, which Ajax requests status is tracked by a component.

  • Definition with the "for" attribute on the <a4j:status> component. Here "for" attribute should point at an Ajax container ( <a4j:region> ) "id", which requests are tracked by a component.

  • Definition with the "status" attribute obtained by any RichFaces library action component. The attribute should point at the <a4j:status> component "id". Then this <a4j:status> component shows the status for the request fired from this action component.

The component creates two <span> or <div> elements depending on attribute "layout" with content defined for each status, one of the elements (start) is initially hidden. At the beginning of an Ajax request, elements state is inversed, hence the second element is shown and the first is hidden. At the end of a response processing, elements display states return to its initial values.

Example:


<a4j:status startText="Started" stopText="stopped" />

is decoded on a page as:


<span id="j_id20:status.start" style="display: none">
      Started
</span>
<span id="j_id20:status.stop">
        Stopped
</span>

And after the generation of an Ajax response is changed to:


<span id="j_id20:status.start">
        Started
</span>
<span id="j_id20:status.stop" style="display: none">
        Stopped
</span>

There is a possibility to group a <a4j:status> elements content into <div> elements, instead of <span> . To use it, just redefine the "layout" attribute from "inline"(default) to "block".

6.4.5. Relevant resources links

Here you can see the example of <a4j:status> usage and sources for the given example.

6.5.  < a4j:portlet >

6.5.1. Description

The <a4j:portlet> can be used in portals. The main component purpose is realization of possibility to create several instances the same portlet on one page.

Table 6.9. a4j : portlet attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
renderedIf "false", this component is not rendered

Table 6.10. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Portlet
component-familyorg.ajax4jsf.component.Portlet
component-classorg.ajax4jsf.component.html.HtmlPortlet

6.5.2. Creating on a page



<f:view>
    <a4j:portlet>
    ...
    </a4j:portlet>
</f:view>

6.5.3. Dynamical creation of a component from Java code



import org.ajax4jsf.component.html.HtmlPortlet;
...
HtmlPortlet myPortlet = new HtmlPortlet();
...

6.5.4. Key attributes and ways of usage

Portal page can include some instances of the same portlet but clientId of elements should be different for each window. In that case 'namespace' is used for each portlet. The <a4j:portlet> implemets NaimingContainer interface and adds namespace to all componets on a page. All portlet content should be wrapped by <a4j:portlet> for resolving problems mentioned before.

6.5.5. Relevant resources links

Here you can see the example of <a4j:portlet> usage and sources for the given example.

The aditional information about component usage you can find here: Ajax4Jsf Users Forum.

6.6.  < a4j:push >

6.6.1. Description

The <a4j:push> periodically perform Ajax request to server, to simulate 'push' data.

Table 6.11. a4j : push attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression.
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
enabledEnable/disable pushing
eventProducerMethodBinding pointing at method accepting an PushEventListener with return type void. User bean must register this listener and send EventObject to this listener on ready.
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
intervalInterval (in ms) for call push requests. Default value 1000 (1 sec)
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
renderedIf "false", this component is not rendered
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutTimeout (in ms) for request

Table 6.12. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Push
component-familyorg.ajax4jsf.components.AjaxPush
component-classorg.ajax4jsf.component.html.AjaxPush
renderer-typeorg.ajax4jsf.components.AjaxPushRenderer

6.6.2. Creating on a page



<a4j:push reRender="msg" eventProducer="#{messageBean.addListener}" interval="3000"/>

6.6.3. Dynamical creation of a component from Java code


import org.ajax4jsf.component.html.AjaxPush;
...
AjaxPush myPush = new AjaxPush();
...

6.6.4. Key attributes and ways of usage

The main difference between <a4j:push> and <a4j:poll> components is that <a4j:push> makes request to minimal code only (not to JSF tree) in order to check the presence of messages in the queue. If a message exists, a complete request will be performed. The component doesn't poll registered beans but registers EventListener which receives messages about events.

There are some attributes which allows to customize of the component behaviour:

"interval" - Interval (in ms) for call push requests. Default value 1000 (1 sec).

Code for registration of listener:



public void addListener(EventListener listener) {
synchronized (listener) {
    if (this.listener != listener) {
    this.listener = (PushEventListener) listener;
}

Component can get message using current code:



System.out.println("event occurs");
synchronized (listener) {
    listener.onEvent(new EventObject(this));
}

Thus, component 'push' uses asynchronous model instead of polls.

6.6.5. Relevant resources links

Here you can see the example of <a4j:push> usage and sources for the given example.

6.7.  < a4j:repeat >

6.7.1. Description

The <a4j:repeat> component implements a basic iteration component allowing to update a set of its children with AJAX.

Table 6.13. a4j : repeat attributes

Attribute NameDescription
ajaxKeysThis attribute defines strings that are updated after an AJAX request.
bindingThe attribute takes a value-binding expression for a component property of a backing bean
componentStateIt defines EL-binding for a component state for saving or redefinition.
firstA zero-relative row number of the first row to display
idEvery component may have a unique id that is automatically created if omitted
renderedIf "false", this component is not rendered
rowKeyVarThe attribute provides access to a row key in a Request scope.
rowsA number of rows to display, or zero for all remaining rows in the table
stateVarThe attribute provides access to a component state on the client side.
valueThe current value for this component.
varA request-scope attribute via which the data object for the current row will be used when iterating

Table 6.14. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Repeat
component-familyjavax.faces.Data
component-classorg.ajax4jsf.component.html.HtmlAjaxRepeat
renderer-typeorg.ajax4jsf.components.RepeatRenderer


6.7.2. Creating on a page

The component definition on a page is the same as for the "facelets" component:


<a4j:repeat id="detail" value="#{bean.props}" var="detail">
    <h:outputText value="#{detail.someProperty}"/>
</a4j:repeat>

The output is generated according to a collection contained in "bean.props" with the "detail" key passed to child components.

6.7.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.HtmlAjaxRepeat;
...
HtmlAjaxRepeat repeater = new HtmlAjaxRepeat ();
...

6.7.4. Key attributes and ways of usage

The main difference of this component from iterative components of other libraries is a special "ajaxKeys" attribute. This attribute defines strings that are updated after an Ajax request. As a result it becomes easier to update several child components separately without updating the whole page.


<a4j:poll intervall="1000" action="#{repeater.action}" reRender="list">
...
<table>
 <tbody>
   <a4j:repeat value="#{bean.props}" var="detail" binding="#{repeater.myRepeat}"
     id="list" ajaxKeys="#{repeater.ajaxedRowsSet}">
     </tr>
       <td>
        <h:outputText value="detail.someProperty">
        </td>
      </tr>
   </a4j:repeat>
   <tbody>
<table>

Thus, a list with a table structure from "bean.props" is output.

In the above-mentioned example the component <a4j:poll> sends Ajax requests every second, calling the "action" method of the "repeater" bean.

Note:

The <a4j:repeater> component is defined as fully updated, but really updated there are only the strings which rowKeys includes into the set "ajaxRowSet" defined in the "ajaxKeys" attribute

The set could be defined during the action method processing using data on a model from the property "repeater.myRepeat"

One more benefit of this component is absence of strictly defined markup as JSF HTML DataTable and Tomahawk DataTable has, hence the components could be used more flexibly anywhere where it's necessary to output the results of selection from some collection.

The next example shows collection output as a plain HTML list


<ul>
      <a4j:repeat ...>
        <li>...<li/>
         ...
        <li>...<li/>
      </a4j:repeat>
</ul>

All other general attributes are defined according to the similar attributes of iterative components ( <h:dataTable> or <ui:repeat> ) and are used in the same way.

6.7.5. Relevant resources links

Here you can see the example of <a4j:repeat> usage and sources for the given example.

6.8.  < a4j:commandButton >

6.8.1. Description

The <a4j:commandButton> component is very similar to the <h:commandButton> component, the only difference is that an Ajax form submit is generated on a click and it allows dynamic rerendering after a response comes back. It's not necessary to plug any support into the component, as Ajax support is already built in.

Table 6.15. a4j : commandButton attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression.
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
altAlternate textual description of the element rendered by this component.
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
disabledWhen set for a form control, this boolean attribute disables the control for user input
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now.
imageAbsolute or relative URL of the image to be displayed for this button. If specified, this "input" element will be of type "image". Otherwise, it will be of the type specified by the "type" property with a label specified by the "value" property.
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
langCode describing the language used in the generated markup for this component
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onfocusHTML: script expression; the element got the focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
sizeThis attribute tells the user agent the initial width of the control. The width is given in pixels except when type attribute has the value "text" or "password". In that case, its value refers to the (integer) number of characters
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
timeoutTimeout ( in ms ) for request.
titleAdvisory title information about markup elements generated for this component
typesubmit|reset|image|button This attribute specifies a type of control to create. The default value for this attribute is "submit"
valueThe current value for this component

Table 6.16. Component identification parameters

NameValue
component-typeorg.ajax4jsf.CommandButton
component-familyjavax.faces.Command
component-classorg.ajax4jsf.component.html.HtmlAjaxCommandButton
renderer-typeorg.ajax4jsf.components.AjaxCommandButtonRenderer


6.8.2. Creating on a page

<a4j:commandButton> is used in the same way as <h:commandButton> , but with definition of the area that is updated after the response comes back from the server.


<a4j:commandButton reRender="someData" action="#{bean.action1}" value="Link"/>

This definition of the component provides a link, a click on the link causes an Ajax form submit on the server, "action1" method performance, and rendering of the component with "someData" id after the response comes back from the server.

6.8.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.HtmlAjaxCommandButton;
...
HtmlAjaxCommandButton myButton = new HtmlAjaxCommandButton();
...

6.8.4. Key attributes and ways of usage

The component <a4j:commandButton> placed on a page generates the following HTML code:


<input type="submit" onclick="A4J.AJAX.Submit(...request parameters);return false;" value="sort"/>

Hence, the utility method "A4J.AJAX.Submit" is called on a click, the method performs Ajax request as the <a4j:support> component

Note:

AJAX support is built in and it's not necessary to add nested <a4j:support> to the component.

Common JSF navigation could be performed after an Ajax submit and partial rendering, but Navigation Case must be defined as <redirect/> in order to avoid problems with some browsers.

As any Core Ajax component sending Ajax requests and processing server responses <a4j:commandButton> has all attributes described above (see <a4j:support> chapter) that provide the required behavior of requests sending (delay, limitation of submit area and rendering, and etc.)

6.8.5. Relevant resources links

Here. you can see the example of <a4j:commandButton> usage and sources for the given example.

6.9.  < a4j:actionparam >

The <a4j:actionparam> component combines the functionality of both JSF components: <f:param> and <f:actionListener> .

More information about <f:param> and <f:actionListener> can be found here.

Table 6.17. a4j : actionparam attributes

Attribute NameDescription
assignToEL expression for updatable bean property. This property will be updated if the parent command component performs an actionEvent.
bindingThe attribute takes a value-binding expression for a component property of a backing bean
converterID of a converter to be used or a reference to a converter.
idEvery component may have a unique id that is automatically created if omitted
nameA name of this parameter
noEscapeIf set to true, the value will not enclosed within single quotes and there will be no escaping of characters. This allows the use of the value as JavaScript code for calculating value on the client-side. This doesn't work with non-AJAX components.
valueAn initial value or a value binding

6.10.  < a4j:loadScript >

6.10.1. Description

Inserts script links to the head element. Render the value of the component as the value of the "src" attribute, after passing it to the getResourceURL() method of the ViewHandler for this application, and passing the result through the encodeResourceURL() method of the ExternalContext.

Table 6.18. a4j : loadScript attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
renderedIf "false", this component is not rendered
srcname of JavaScript resource to load.

Table 6.19. Component identification parameters

NameValue
component-typeorg.ajax4jsf.LoadScript
component-familyorg.ajax4jsf.LoadScript
component-classorg.ajax4jsf.component.html.HtmlLoadScript
renderer-typeorg.ajax4jsf.LoadScriptRenderer

6.10.2. Creating on a page

Simple Component definition on a page:

Example:


<a4j:loadScript src="scripts/someScript.js"/>

6.10.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.HtmlLoadScript;
...
HtmlLoadScript myScript = new HtmlLoadScript();
...

6.10.4. Key attributes and ways of usage

As it was mentioned above this component returns its value passing it to the getResourceUR() method of the ViewHandler for this application, and passing the result through the encodeResourceURL() method of the ExternalContext.

It means that the Context will be inserts automatically to the link. And calls like resource:// will be properly handled.

Except this - you may be free to put your script links right from the child page while using facelets templates .

6.10.5. Relevant resources links

Here you can see the example of <a4j:loadScript>s usage and sources for the given example.

6.11.  < a4j:outputPanel >

6.11.1. Description

The component is used for components grouping in the Ajax output area, which offers several additional output opportunities such as inserting of non-present in tree components, saving of transient elements after Ajax request and some others.

Table 6.20. a4j : outputPanel attributes

Attribute NameDescription
ajaxRenderedDefines, whether the content of this component must be (or not) included in AJAX response created by parent AJAX Container, even if it is not forced by reRender list of ajax action. Ignored if component marked to output by Ajax action. default false
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
idEvery component may have a unique id that is automatically created if omitted
keepTransientFlag for mark all child components to non-transient. If true, all children components will be set to non-transient state and keep in saved components tree. For output in self-renderer region all content ( By default, all content in <f:verbatim> tags and non-jsf elements in facelets, marked as transient - since, self-rendered ajax regions don't plain output for ajax processing ).
langCode describing the language used in the generated markup for this component
layoutHTML layout for generated markup. Possible values: "block" for generating an HTML <div> element, "inline" for generating an HTML <span> element, and "none" for generating no HTML element. There is a minor exception for the "none" case where a child element has the property "rendered" set to "false". In this case, we create an empty <span> element with same ID as the child element to use as a placeholder for later processing.
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component

Table 6.21. Component identification parameters

NameValue
component-typeorg.ajax4jsf.OutputPanel
component-familyjavax.faces.Panel
component-typeorg.ajax4jsf.ajax.OutputPanel
component-classorg.ajax4jsf.component.html.HtmlAjaxOutputPanel
renderer-typeorg.ajax4jsf.components.AjaxOutputPanelRenderer

6.11.2. Creating on a page

Here is the simplest way for a component creation on a page.

Example:


<a4j:outputPanel>
<!--...Some Content Inside-->
</a4j:outputPanel>

6.11.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.HtmlAjaxOutputPanel;
...
HtmlAjaxOutputPanel  myPanel = new HtmlAjaxOutputPanel();

6.11.4. Key attributes and ways of usage

<a4j:outPanel> allows marking of a page area, which is updated on Ajax response. Anyway, <a4j:outputPanel> usage is optional, as in RichFaces it's possible to indicate any existing component id on a component view in order to define updating areas. To speed up the performance, RichFaces updates only a component tree. <a4j:outputPanel> usage is recommended for wrapping components that aren't rendered during the primary non-ajax response, as the components don't present in a component tree.

Example:


<a4j:support ... reRender="mypanel"/>
...
<a4j:outputPanel id="mypanel">
  <h:panelGrid rendered="#{not empty foo.bar}">
    ...
  </h:panelGrid>
</a4j:outputPanel>

In addition to the areas directly indicated in "reRender" attribute of Ajax components, <a4j:outputPanel> allows to update a part of a page basing on its own flag. The flag is defined by the "ajaxRendered" attribute. The flag is commonly used when a part of a page must be updated or can be updated on any response.

Example:


<a4j:outputPanel ajaxRendered="true">
  <h:messages/>
</a4j:outputPanel>

On default <a4j:outputPanel> is output as a pair of opening and closing html <span> tag, but with the help of the layout attribute this output way could be changed. There are three variants for this component value:

  • inline (default)
  • block
  • none

If layout="block" is chosen, the component is rendered as a pair of opening and closing <div> tag, to which it’s possible to apply any available style attributes available for block tags.

Layout="none" helps to avoid an unnecessary tag round a context that could or couldn't be rendered according to the defined "rendered" attribute conditions. If an inner context isn’t rendered, <a4j:outputPanel> is rendered as a <span> tag with the id equal to an id of a child component and "display:none" style. If a child component is rendered, <a4j:outputPanel> doesn't present at all in a final code.

Example:


<a4j:support .... reRender="mypanel"/>
...
<a4j:outputPanel layout="none">
  <h:panelGrid id="mypanel" rendered="#{not empty foo.bar}">
    ...
  </h:panelGrid>
</a4j:outputPanel>

As you see, the code is very similar to the one shown above, but "reRender " attribute refers directly to the updating panelGrid and not to the framing outputPanel, and it's more semantically correct.

<a4j:outPanel> should be used for non-JSF component part framing, which is to be updated on Ajax response, as RichFaces specifies the list of updating areas as a list of an existing JSF component.

On default non-JSF context isn't saved in a component tree, but is rendered anew every time. To accelerate the processing speed and Ajax response input speed, RichFaces saves non-JSF context in a component tree on default. This option could be canceled by "keepTransient" attribute that cancels transient flag forced setting for child components. This flag setting keeps the current value set by child components.

Note: In JSF 1.1 implementation and lower, where non-JSF context should be framed with the "f:verbatim" attribute, <a4j:outputPanel> doesn't improve this JSF implementation option in any way, so you still have to use this tag where it's necessary without RichFaces usage.

RichFaces allows setting Ajax responses rendering directly basing on component tree nodes without referring to the JSP (XHTML) page code. It could be defined by selfRendered attribute setting to "true" on <a4j:region> and could help considerably speed up a response output. However, if a transient flag is kept as it is, this rapid processing could cause missing of transient components that present on view and don’t come into a component tree. Hence, for any particular case you could choose a way for you application optimization: speed up processing or redundant memory for keeping tree part earlier defined a transient.

6.11.5. Relevant resources links

Here you can see the example of <a4j:outputPanel> usage and sources for the given example.

Some additional information about usage of component can be found here.

6.12.  < a4j:loadBundle >

The <a4j:loadBundle> component is similar to the same component from the JSF Core library. The component loads a resource bundle localized for the Locale of the current view and exposes it (as a Map) in the request attributes of the current request.

Table 6.22. a4j : loadBundle attributes

Attribute NameDescription
basenameBase name of the resource bundle to be loaded.
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
renderedIf "false", this component is not rendered
varName of a request scope attribute under which the resource bundle will be exposed as a Map.

Table 6.23. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Bundle
component-familyorg.ajax4jsf.Bundle
component-classorg.ajax4jsf.component.html.AjaxLoadBundle

6.12.1. Creating on a page

Simple component definition on a page:

Example:


<a4j:loadBundle baseName="demo.bundle.Messages" var="Message"/>

6.12.2. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.AjaxLoadBundle;
...
AjaxLoadBundle myBundle = new AjaxLoadBundle();
...
        

6.12.3. Key attributes and ways of usage

<a4j:loadBundle> allows to use reference to bundle messages during the Ajax re-rendering. <a4j:loadBundle> is a substitute for the <f:loadBundle> in JSF 1.1 which is not a JSF component originally. <f:loadBundle> is a jsp tag that load the bundle messages into the request scope when page is rendered. As soon as each Ajax request works in own request scope, the bundles loaded with <f:loadBundle> are unavailable. Instead of <f:loadBundle> that might be located anywhere on a page, the <a4j:loadBundle> should be declared inside the <f:view> (this does not matter in case on using Facelets) JSF 1.2 introduces the bundle registered in the faces-config.xml. This fixed the problem with <f:loadBundle> . Therefore, you can use this JSF 1.2 way to declare your bundles.

6.12.4. Relevant resources links

Here you can see the example of <a4j:loadBundle> usage and sources for the given example.

6.13.  < a4j:mediaOutput >

6.13.1. Description

The <a4j:mediaOutput> component implements one of the basic features specified in the framework. The component is a facility for generating images, video, sounds and other binary resources defined by you on-the-fly.

Table 6.24. a4j : mediaOutput attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
alignbottom|middle|top|left|right Deprecated. This attribute specifies the position of an IMG, OBJECT, or APPLET with respect to its context. The following values for align concern the object's position with respect to surrounding text: * bottom: means that the bottom of the object should be vertically aligned with the current baseline. This is the default value. * middle: means that the center of the object should be vertically aligned with the current baseline. * top: means that the top of the object should be vertically aligned with the top of the current text line
archivespace-separated list of URIs
bindingThe attribute takes a value-binding expression for a component property of a backing bean
borderDeprecated. This attribute specifies the width of an IMG or OBJECT border, in pixels. The default value for this attribute depends on the user agent
cacheableIf "true", the resource is cached (on the server and the client sides).
charsetThe character encoding of a resource designated by this hyperlink
classididentifies an implementation
codebasebase URI for classid, data, archive
codetypecontent type for code
converterID of a converter to be used or a reference to a converter.
coordsThis attribute specifies the position and shape on the screen. The number and order of values depends on the shape being defined. Possible combinations: * rect: left-x, top-y, right-x, bottom-y. * circle: center-x, center-y, radius. Note. When the radius value is percentage value, user agents should calculate the final radius value based on the associated object's width and height. The radius should be the smaller value of the two. * poly: x1, y1, x2, y2, ..., xN, yN. The first x and y coordinate pair and the last should be the same to close the polygon. When these coordinate values are not the same, user agents should infer an additional coordinate pair to close the polygon. Coordinates are relative to the top, left corner of the object. All values are lengths. All values are separated by commas
createContentMethod call expression to send generated resource to OutputStream. It must have two parameter with a type of java.io.OutputStream and java.lang.Object ( deserialized value of data attribute )
declaredeclare but don't instantiate flag
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
elementName of html element for resource link - may be <a> <img> <object> <applet> <script> or <link>
expiresThe attribute allows to manage caching and defines the period after which a resource is reloaded.
hreflangBase language of a resource specified with the href attribute; hreflang may only be used with href
hspaceDeprecated. This attribute specifies the amount of white space to be inserted to the left and right of an IMG, APPLET, or OBJECT. The default value is not specified, but is generally a small, non-zero length
idEvery component may have a unique id that is automatically created if omitted
ismapuse server-side image map
langCode describing the language used in the generated markup for this component
lastModifiedThe attribute allows to manage caching. A browser can send request with the header "If-Modified-Since" for necessity of object reloading. If time of modification is earlier, then the framework doesn't call generation and return code 304.
mimeTypeGeterated content mime-type for append to response header ( 'image/jpeg' etc )
onblurJavaScript code. The onblur event occurs when an element loses focus either by the pointing device or by tabbing navigation. It may be used with the same elements as onfocus
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onfocusJavaScript code. The onfocus event occurs when an element gets focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
relThe relationship from the current document to the anchor specified by this hyperlink. The value of this attribute is a space-separated list of link types
renderedIf "false", this component is not rendered
revA reverse link from the anchor specified by this hyperlink to the current document. The value of this attribute is a space-separated list of link types
sessionIf "true", a session for an object generation is restored.
shapedefault|rect|circle|poly [CI] This attribute specifies the shape of a region. Possible values: * default: Specifies the entire region. * rect: Define a rectangular region. * circle: Define a circular region. * poly: Define a polygonal region.
standbymessage to show while loading
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
targetThis attribute specifies the name of a frame where a document is to be opened. By assigning a name to a frame via the name attribute, authors can refer to it as the "target" of links defined by other elements
titleAdvisory title information about markup elements generated for this component
typeThe content type of the resource designated by this hyperlink
uriAttributeName of attribute for resource-link attribute ( 'href' for <a>, 'src' for <img> or <script>, etc
usemapuse client-side image map
valueData value calculated at render time and stored in URI (also as part of cache Key ), at generation time passed to send method. Can be used for update cache at change of generating conditions, and for creating beans as "Lightweight" pattern components (request scope). IMPORTANT: Since serialized data stored in URI, avoid using big objects.
vspaceDeprecated. This attribute specifies the amount of white space to be inserted above and below an IMG, APPLET, or OBJECT. The default value is not specified, but is generally a small, non-zero length

Table 6.25. Component identification parameters

NameValue
component-typeorg.ajax4jsf.MediaOutput
component-familyorg.ajax4jsf.Resource
component-classorg.ajax4jsf.component.html.MediaOutput
renderer-typeorg.ajax4jsf.MediaOutputRenderer

6.13.2. Creating on a page

To use the component it's necessary to define it on a page and set Java methods for data keeping and data transmission to output stream.

Component definition on a page for graphical data output

Example:


...
<a4j:mediaOutput element="img" cacheable="false" session="true"
    createContent="#{paintBean.paint}" value="#{paintData}"
    mimeType="image/jpeg"/>
...

Here is the content of paintData that is a bean containing output data

Example:


package demo;

public class PaintData implements Serializable{
        private static final long serialVersionUID = 1L;
        Integer width=100;
        Integer weight=50;
...

The Paint method of the paintBean class is a method transmitting graphical data into output stream.

Example:


public void paint(OutputStream out, Object data) throws IOException{
    <!--...Some code that puts binary data to "out" Stream-->
        }

6.13.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.MediaOutput;
...
MediaOutput myMedia = new MediaOutput ();
...

6.13.4. Key attributes and ways of usage

As it was shown in the example above there are two main components:

  • "createContent" specifies a method accepting 2 parameters. The first (of java.io.OutputStream type) defines a stream, where any binary data is output. The second (of java.lang.Object type) contains deserialized object with data specified in the "value" attribute.
  • Value specifies a bean class keeping data for transmitting into a method that transmits it into a stream.

Note:

A bean class transmitted into value should implement Serializable interface.

Hence, when using the component it's possible to output your data of any type on a page with Ajax requests.

6.13.5. Relevant resources links

Here you can see the example of <a4j:mediaOutput > usage and sources for the given example.

6.14.  < a4j:log >

6.14.1. Description

The <a4j:log > component generates JavaScript for opening of the window with client-side debug information on an Ajax request.

Table 6.26. a4j : log attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
heightheight of pop-up
hotkeyKeyboard key for activate ( in combination with CTRL+SHIFT ) log window.
idEvery component may have a unique id that is automatically created if omitted
levellog level, possible values : FATAL,ERROR,WARN,INFO,DEBUG,ALL. Component set level 'ALL' by default.
namename of pop-up window
popupRender log as popup-window or as div element in page
renderedIf "false", this component is not rendered
widthwidth of pop-up.

Table 6.27. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Log
component-familyorg.ajax4jsf.Log
component-classorg.ajax4jsf.component.html.AjaxLog
renderer-typeorg.ajax4jsf.LogRenderer


6.14.3. Creating on a page

To use the component, it's necessary to place the following string on a page:


<a4j:log/>

Then, in order to open a log window, press "CTRL+SHIFT+L" on a page with the component.

6.14.4. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.AjaxLog;
...
AjaxLog myLog = new AjaxLog();
...

6.14.5. Key attributes and ways of usage

Usage of the appropriate component attributes could change a representation level of debug information as well as the hot key for a window opening.

The hot key could be changed with the "hotkey" attribute, where it's necessary to define one letter that together with "CTRL+SHIFT" opens a window.

The "level" attribute with several possible values (FATAL, ERROR, WARN, INFO, ALL) could change a logging level.

The log could be generated not only in a new window, but also on the current page in a separate <div> , this is also controlled with the "popup" attribute on the component.

Example:


<a4j:log level="ALL" popup="false" width="400" height="200"/>

The component defined this way is decoded on a page as <div> inside a page, where all the information beginning with informational message is generated.

Note:

<a4j:log> is getting renewed automatically after execution of Ajax requests. Don't renew <a4j:log> by using reRender!

6.14.6. Relevant resources links

Here you can see the example of <a4j:log> usage and sources for the given example.

6.15.  < a4j:region >

6.15.1. Description

The <a4j:region> component defines an area that is decoded on the server after Ajax submission.

Table 6.28. a4j : region attributes

Attribute NameDescription
ajaxListenerMethodBinding representing an action listener method that will be notified when this component is activated by the ajax Request and handle it. The expression must evaluate to a public method that takes an AjaxEvent parameter, with a return type of void
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
immediateFlag indicating that, if this component is activated by ajaxrequest, notifications should be delivered to interested listeners and actions immediately (that is, during Apply Request Values phase) rather than waiting until Invoke Application phase
renderedIf "false", this component is not rendered
renderRegionOnlyFlag to disable rendering in AJAX responses content outside of active region. If this attribute set to "true" , no one of the components outside of region will be included to AJAX response. If set to "false", search for components to include in response will be performed on all tree. Default "false"
selfRenderedif "true", self-render subtree at InvokeApplication ( or Decode, if immediate property set to true ) phase

Table 6.29. Component identification parameters

NameValue
component-typeorg.ajax4jsf.AjaxRegion
component-familyorg.ajax4jsf.AjaxRegion
component-classorg.ajax4jsf.component.html.HtmlAjaxRegion
renderer-typeorg.ajax4jsf.components.AjaxRegionRenderer

6.15.2. Creating on a page

Here is an example of the region decoding on a page.


<a4j:region>
    <!--..Some content that will be decoded on server after Ajax request.-->
</a4j:region>

6.15.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.HtmlAjaxRegion;
...
HtmlAjaxRegion newRegion = new HtmlAjaxRegion();
...

6.15.4. Key attributes and ways of usage

The region is a component used for manipulation with components sent to the server. It sets particular processing parameters for an area on the server, i.e. the region deals with data input on the server and has no direct impact on output. To read more on the components responsible for out, see "reference"

The region marks an area page that is decoded on the server. In most cases it is not necessary to use the region, as ViewRoot is a default region. This component helps to reduce data quantity processed by the server, but the region doesn't influence on the standard submission rules. It means that:

  • The area that is to be submitted onto the server should be embedded in <h:form/a4j:form> component.
  • The whole form is submitted on Ajax response and not a region that request is performed from.

Example:


<h:form id="form1">
    <a4j:region>
        <a4j:commandLink reRender="someID" value="Link" id="link1"/>
        <!--..Some content that will be decoded on server after Ajax request.-->
    </a4j:region>
<h:form>

Hence, the <a4j:commandLink> request generation causes full "form1" form submission onto the server, the only difference is that a component tree part decoded on the serve is the part included into the region.

The regions could be nested in any order, the server picks out and decodes only the region, which contains a particular component that sends a request.

Example:


<a4j:region>
    <a4j:commandLink reRender="someID" value="Link" id="link1"/>
    <a4j:region>
        <a4j:commandLink reRender="someID" value="Link" id="link2"/>
        <!--..Some content that will be decoded on server after Ajax request.-->
    </a4j:region >
    <!--..Some content that will be decoded on server after Ajax request.-->
</a4j:region >

Therefore, the external region is decoded for the "link1" and the internal one is decoded for the "link2".

RichFaces allows setting Ajax responses rendering directly basing on component tree nodes without referring to the JSP (XHTML) page code. It could be defined by "selfRendered" attribute setting to "true" on <a4j:region> and could help considerably speed up a response output. However, this rapid processing could cause missing of transient components that present on view and don't come into a component tree as well as omitting of <a4j:outputPanel> usage described below.

Example:


<a4j:region selfRendered ="true">
    <a4j:commandLink reRender="someID" value="Link" id="link1"/>
    <!--..Some content with HTML used ("br" ,"h1" and other tags used)-->
</a4j:region >

In this case, the processing is quicker and going on without referring to a page code, but the HTML code that isn't saved in a component tree could be lost. Thus, this optimization should be very carefully performed and a usage of the additional components RichFaces ( <a4j:outputPanel> ) is required.

The processing could be also accelerated if a region decoded for the processing passes straight away into Encode. But to update some data out of the region or on another region, use the "renderRegionOnly" attribute set to "false" ("true on default") to change this behaviour.

Example:


<a4j:region renderRegionOnly="true">
    <a4j:commandLink reRender="someID2" value="Link1" id="link1"/>
    <h:panelGroup id="someId1">
    </h:panelGroup>
</a4j:region>
<a4j:region renderRegionOnly="false">
    <a4j:commandLink reRender="someID1" value="Link2" id="link2"/>
    <h:panelGroup  id="someId1">
    </h:panelGroup>
</a4j:region>

This example shows that one of the regions is decoded when a link is used inside. Nevertheless, if after processing the "link1" is clicked, the first region passes into Encode as a root region and encode performance time is reduced. This optimization doesn't allow data update out of the region and should be implemented very carefully. The data out of the region described with "renderRegionOnly" ="false" is updated successfully.

6.15.5. Relevant resources links

Here you can see the example of <a4j:region> usage and sources for the given example.

6.16.  < a4j:form >

6.16.1. Description

The <a4j:form> component is very similar to the same component from the JSF HTML library, the only slight difference is in generation of links inside and possibility of Ajax by-default submission.

Table 6.30. a4j : form attributes

Attribute NameDescription
acceptThis attribute specifies a comma-separated list of content types that a server processing this form will handle correctly. User agents may use this information to filter out non-conforming files when prompting a user to select files to be sent to the server (cf. the INPUT element when type="file")
acceptCharsetThis attribute specifies the list of character encodings for input data that is accepted by the server processing this form. The value is a space- and/or comma-delimited list of charset values. The client must interpret this list as an exclusive-or list, i.e., the server is able to accept any single character encoding per entity received. The default value for this attribute is the reserved string "UNKNOWN". User agents may interpret this value as the character encoding that was used to transmit the document containing this FORM element
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
ajaxSubmitIf true, it becomes possible to set AJAX submission way for any components inside .
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
enctypeThis attribute specifies the content type used to submit the form to the server (when the value of method is "post"). The default value for this attribute is "application/x-www-form-urlencoded". The value "multipart/form-data" should be used in combination with the INPUT element, type="file"
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
onresetThe onreset event occurs when a form is reset. It only applies to the FORM element
onsubmitThe onsubmit event occurs when a form is submitted. It only applies to the FORM element
prependIdThe flag indicating whether or not this form should prepend its id to its descendent id during the clientId generation process. If this flag is not set, the default value is true.
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
statusID (in format of call UIComponent.findComponent()) of Request status component
targetThis attribute specifies the name of a frame where a document is to be opened. By assigning a name to a frame via the name attribute, authors can refer to it as the "target" of links defined by other elements
timeoutTimeout ( in ms ) for request.

Table 6.31. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Form
component-familyjavax.faces.Form
component-classorg.ajax4jsf.component.html.AjaxForm
renderer-typeorg.ajax4jsf.FormRenderer

6.16.2. Creating on a page

Component definition on a page is similar to definition of the original component from JSF HTML library.


<a4j:form>
    <!--...Some content to be submitted.-->
</a4j:form>

6.16.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.AjaxForm;
...
AjaxForm myForm = new AjaxForm();
...

6.16.4. Key attributes and ways of usage

The difference with the original component is that all hidden fields required for command links are always rendered and it doesn't depend on links rendering on the initial page. It solves the problem with invalid links that weren't rendered on a page immediately, but after some Ajax request.

Beginning with release 1.0.5 additional attributes that make this form variant universal have appeared. With a new attribute definition as ajax= "true" , it becomes possible to set Ajax submission way for any components inside, i.e. not a page URL is used as an "action" attribute, but the javascript:A4J.AJAX.Submit(...) call. In this case, rendering is defined as "reRender"=list of Ids for the form element itself.

Example


<a4j:form id="helloForm" ajaxSubmit="true" reRender="table">
    ...
    <t:dataTable id="table"... >
        ...
    </t:dataTable>
    ...
    <t:dataScroller for="table"... >
        ...
    </t:dataScroller>
    ...
</a4j:form

This example shows that in order to make <t:dataScroller> submissions to be Ajax ones it's required only to place this <t:dataScroller> into <a4j:form> . In the other case it is necessary to redefine renders for its child links elements that are defined as <h:commandLink> and can't be made Ajax ones with using e.g. <a4j:support> .

6.16.5. Relevant resources links

Here. you can see the example of <a4j:form> usage and sources for the given example.

6.17.  < a4j:htmlCommandLink >

6.17.1. Description

The <a4j:htmlCommandLink> component is very similar to the same component from the JSF HTML library, the only slight difference is in links generation and problem solving that occurs when an original component is used.

Table 6.32. a4j : htmlCommandLink attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression.
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
bindingThe attribute takes a value-binding expression for a component property of a backing bean
charsetThe character encoding of a resource designated by this hyperlink
coordsThis attribute specifies the position and shape on the screen. The number and order of values depends on the shape being defined. Possible combinations: * rect: left-x, top-y, right-x, bottom-y. * circle: center-x, center-y, radius. Note. When the radius value is percentage value, user agents should calculate the final radius value based on the associated object's width and height. The radius should be the smaller value of the two. * poly: x1, y1, x2, y2, ..., xN, yN. The first x and y coordinate pair and the last should be the same to close the polygon. When these coordinate values are not the same, user agents should infer an additional coordinate pair to close the polygon. Coordinates are relative to the top, left corner of the object. All values are lengths. All values are separated by commas
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
disabledWhen set for a form control, this boolean attribute disables the control for user input.
hreflangBase language of a resource specified with the href attribute; hreflang may only be used with href
idEvery component may have a unique id that is automatically created if omitted
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
langCode describing the language used in the generated markup for this component
onblurJavaScript code. The onblur event occurs when an element loses focus either by the pointing device or by tabbing navigation. It may be used with the same elements as onfocus
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onfocusJavaScript code. The onfocus event occurs when an element gets focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
relThe relationship from the current document to the anchor specified by this hyperlink. The value of this attribute is a space-separated list of link types
renderedIf "false", this component is not rendered
revA reverse link from the anchor specified by this hyperlink to the current document. The value of this attribute is a space-separated list of link types
shapedefault|rect|circle|poly [CI] This attribute specifies the shape of a region. Possible values: * default: Specifies the entire region. * rect: Define a rectangular region. * circle: Define a circular region. * poly: Define a polygonal region.
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
targetThis attribute specifies the name of a frame where a document is to be opened. By assigning a name to a frame via the name attribute, authors can refer to it as the "target" of links defined by other elements
titleAdvisory title information about markup elements generated for this component
typeThe content type of the resource designated by this hyperlink
valueThe current value for this component

Table 6.33. Component identification parameters

NameValue
component-typejavax.faces.HtmlCommandLink
component-familyjavax.faces.Command
component-classjavax.faces.component.html.HtmlCommandLink
renderer-typeorg.ajax4jsf.HtmlCommandLinkRenderer

6.17.2. Creating on a page

Component definition on a page is the same as for the original component from the JSF HTML library.

Example:


<a4j:htmlCommandLink value="value" action="action"/>

6.17.3. Dynamical creation of a component from Java code

Example:


import javax.faces.component.html.HtmlCommandLink;
...
HtmlCommandLink myCommandLink = new HtmlCommandLink();
...

6.17.4. Key attributes and ways of usage

The difference with the original component is that all hidden fields required for command links with the child <f:param> elements are always rendered and it doesn't depend on links rendering on the initial page. It solves the problem with invalid links that weren't rendered on a page immediately, but after some Ajax request.

Example:


<a4j:form>
    ...
    <a4j:htmlComandLink action="action" value="link" rendered="#{bean.rendered}">
        <f:param ...>
    <a4j:htmlComandLink>
    ...
</a4j:form>

In this example <a4j:htmlCommandLink> works as standard <h:commandLink> , but here hidden fields required for correct functionality are rendered before the first downloading of a page, though it doesn't happen if its attribute isn't set to "false".

6.17.5. Relevant resources links

Here you can see the example of <a4j:htmlCommandLinks> usage and sources for the given example.

6.18.  < a4j:commandLink >

6.18.1. Description

The <a4j:commandLink> component is very similar to the <h:commandLink> component, the only difference is that an Ajax form submit is generated on a click and it allows dynamic rerendering after a response comes back. It's not necessary to plug any support into the component, as Ajax support is already built in.

Table 6.34. a4j : commandLink attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression.
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
charsetThe character encoding of a resource designated by this hyperlink
coordsThis attribute specifies the position and shape on the screen. The number and order of values depends on the shape being defined. Possible combinations: * rect: left-x, top-y, right-x, bottom-y. * circle: center-x, center-y, radius. Note. When the radius value is percentage value, user agents should calculate the final radius value based on the associated object's width and height. The radius should be the smaller value of the two. * poly: x1, y1, x2, y2, ..., xN, yN. The first x and y coordinate pair and the last should be the same to close the polygon. When these coordinate values are not the same, user agents should infer an additional coordinate pair to close the polygon. Coordinates are relative to the top, left corner of the object. All values are lengths. All values are separated by commas
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
hreflangBase language of a resource specified with the href attribute; hreflang may only be used with href
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
langCode describing the language used in the generated markup for this component
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onblurJavaScript code. The onblur event occurs when an element loses focus either by the pointing device or by tabbing navigation. It may be used with the same elements as onfocus
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onfocusJavaScript code. The onfocus event occurs when an element gets focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
relThe relationship from the current document to the anchor specified by this hyperlink. The value of this attribute is a space-separated list of link types
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
revA reverse link from the anchor specified by this hyperlink to the current document. The value of this attribute is a space-separated list of link types
shapedefault|rect|circle|poly [CI] This attribute specifies the shape of a region. Possible values: * default: Specifies the entire region. * rect: Define a rectangular region. * circle: Define a circular region. * poly: Define a polygonal region.
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
targetThis attribute specifies the name of a frame where a document is to be opened. By assigning a name to a frame via the name attribute, authors can refer to it as the "target" of links defined by other elements
timeoutTimeout ( in ms ) for request.
titleAdvisory title information about markup elements generated for this component
typeThe content type of the resource designated by this hyperlink
valueThe current value for this component

Table 6.35. Component identification parameters

NameValue
component-typeorg.ajax4jsf.CommandLink
component-familyjavax.faces.Command
component-classorg.ajax4jsf.component.html.HtmlAjaxCommandLink
renderer-typeorg.ajax4jsf.components.AjaxCommandLinkRenderer


6.18.2. Creating on a page

<a4j:commandLink> is used in the same way as <h:commandLink> , but with definition of the area that is updated after the response comes back from the server.


<a4j:commandLink reRender="someData" action="#{bean.action1}" value="Link"/>

This definition of the component provides a link, and a click on the link causes an Ajax form submit on the server, "action1" method performance, and rendering of the component with "someData" id after the response comes back from the server.

6.18.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.HtmlAjaxCommandLink;
...
HtmlAjaxCommandLink myLink = new HtmlAjaxCommandLink();
...

6.18.4. Key attributes and ways of usage

The component <a4j:commandLink> placed on a page generates the following HTML code:


<a href="#" onclick="A4J.AJAX.Submit(?"request parameters");
      return 
      <a href="#" onclick="A4J.AJAX.Submit(?"request parameters");
      return false;">
      <span style="color: black;">Link Value</span>
      </a>

Hence, the utility method "A4J.AJAX.Submit" is called on a click, the method performs Ajax request as the <a4j:support> component

Note:

AJAX support is built in and it's not necessary to add nested <a4j:support> to the component.

Common JSF navigation could be performed after Ajax submit and partial rendering, but Navigation Case must be defined as <redirect/> in order to avoid problems with some browsers.

As any Core Ajax component sending Ajax requests and processing server responses <a4j:commandLink> has all attributes described above (see <a4j:support> chapter) that provide the required behavior of requests sending (delay, limitation of submit area and rendering, etc.)

6.18.5. Relevant resources links

Here you can see the example of <a4j:commandLink> usage and sources for the given example

6.19.  < a4j:support >

6.19.1. Description

The <a4j:support> component adds an Ajax support to any existing JSF component. It allows a component to generate asynchronous requests on the necessary event demand and with partial update of page content after a response incoming from the server.

Table 6.36. a4j : support attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression.
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disableDefaultDisable default action for target event ( append "return false;" to javascript )
eventName of JavaScript event property ( onclick, onchange, etc.) of parent component, for which we will build AJAX submission code
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
onsubmitJavaScript code for call before submission of ajax event
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutTimeout (in ms) for request

Table 6.37. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Support
component-familyorg.ajax4jsf.AjaxSupport
component-classorg.ajax4jsf.component.html.HtmlAjaxSupport
renderer-typeorg.ajax4jsf.components.AjaxSupportRenderer

6.19.2. Creating on a page

To use a component, place <a4j:support> as nested to the component requesting Ajax functionality and specify an event of a parent component that generates Ajax request and the components to be rerendered after a response from the server.

Example:


<h:inputText value="#{bean.text}">
    <a4j:support event="onkeyup" reRender="repeater"/>
</h:inputText>
<h:outputText id="repeater" value="#{bean.text}"/>

On every keyup event generated by an input field, a form is submitted on the server with the help of Ajax and on a response coming from the server, element with "repeater" id, founded in a DOM tree is redrawn according to a new data from the response.

6.19.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.HtmlAjaxSupport;
...
HtmlAjaxSupport mySupport = new HtmlAjaxSupport();>

6.19.4. Key attributes and ways of usage

A4j support addition is very similar to correspondent event redefinition of a component, i.e.

Example:


<h:inputText value="#{bean.text}">
    <a4j:support event="onkeyup" reRender="repeater"/>
</h:inputText>

Is decoded on a page as:

Example:



<input  onkeyup="A4J.AJAX.Submit( Some request parameters )"/>

As you see from the code, the "onkeyup" event calls a utility RichFaces method that submit a form creating a special marks for a filter informing that it is an Ajax request. Thus, any supports quantity could be added to every component, the supports define component behavior on these events.

Note

The components: <a4j:commandLink> , <a4j:commandButton> , <a4j:poll> and others from RichFaces library are already supplied with <a4j:support> functionality and there is no necessity to add the support to them.

With the help of "onsubmit" and "oncomplete" attributes the component allows using JavaScript before (for request sending conditions checking) and after an Ajax response processing termination (for performance of user-defined activities on the client)

Example:


<h:selectOneMenu value="#{bean.text}">
    <f:selectItem itemValue="First Item " itemLabel="First Item"/>
    <f:selectItem itemValue=" Second Item " itemLabel="Second Item"/>
    <f:selectItem itemValue=" Third Item " itemLabel="Third Item"/>
        <a4j:support event="onblur" reRender="panel" onsubmit="if(!confirm('Are you sure to change the option ?')) 
                    {form.reset(); return false;}" oncomplete="alert('Value succesfully stored')"/>
</h:selectOneMenu>

In example there is the condition checking (confirm) is used before request sending and message printing after the request processing is over.

The components allows different Ajax request managing ways for its various optimization in particular conditions such as:

  • Limitation of the submit area and updating area for the request.

    "ajaxSingle" is an attribute that allows submission on the server only component sending a request, as if the component presented on a separate form.

    "limitToList" is an attribute that allows to limit areas, which are updated after the responses. Only these components defined in the "reRender" attribute are updated.

Example 1:


<h:form>
    <h:inputText value="#{person.name}">
        <a4j:support event="onkeyup" reRender="test" ajaxSingle="true"/>
    </h:inputText>
    <h:inputText value="#{person.middleName}"/>
</form>

In this example the request contains only the input component causes the request generation, not all the components contained on a form, because of "ajaxSingle=true" usage.

Example 2:


<h:form>
    <a4j:outputPanel ajaxRendered="true">
        <h:messages/>
    </a4j:outputPanel>
    <h:inputText value="#{person.name}">
        <a4j:support event="onkeyup" reRender="test" limitToList="true"/>
    </h:inputText>
    <h:outputText value="#{person.name}" id="test"/>
</form>

In this example the component "h:messages" is always updated (as it capturing all Ajax requests, located in ajaxRendered <a4j:outputPanel> ), except the case when a response is sent from the input component from the example. On sending this component marks that updating area is limited to the defined in it components, it means that on its usage with "limitToList" ="true" the only component updated is the one with "d"="test".

  • Limitation of requests frequency and updates quantity after the responses.

    "requestDelay" is an attribute that defines a time interval in seconds minimally permissible between responses.

    "eventQueue" is an attribute for naming of the queue where the next response is kept in till its processing, but if the next event comes in till this time is over, the waiting event is taken away, replacing with a new one.

    "ignoreDupResponces" is an attribute that allows to disable any updates on the client after an Ajax request if another Ajax request is already sent.

    "timeout" is an attribute that allows to set a time interval in millisecond to define a maximum time period of response wait time. In case of the interval interaction, a new request is sent and the previous one is canceled. Postprocessing of a response isn't performed.

    Example:

    
    <h:form>
        <h:inputText value="#{person.name}">
           <a4j:support event="onkeyup" reRender="test" 
           requestDelay="1000" ignoreDupResponces="true" eventsQueue="myQueue"/>
        </h:inputText>
        <h:outputText value="#{person.name}" id="test"/>
    </form>

    This example clearly shows mentioned above attributes. If quick typing in a text field happens, every next requests sending is delayed for a second and requests quantity is reduced. The requests are kept in the queue till its the sending. Moreover, if the next request is already sent, the rerendering after the previous request is banned, and it helps to avoid unnecessary processing on the client.

6.19.5. Relevant resources links

Here you can see the example of <a4j:support> usage and sources for the given example.

6.20.  < a4j:loadStyle >

6.20.1. Description

Inserts stylesheet links to the head element. Render the value of the component as the value of the "src" attribute, after passing it to the getResourceURL() method of the ViewHandler for this application, and passing the result through the encodeResourceURL() method of the ExternalContext.

Table 6.38. a4j : loadStyle attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
renderedIf "false", this component is not rendered
srcname of JavaScript resource to load.

Table 6.39. Component identification parameters

NameValue
component-typeorg.ajax4jsf.LoadStyle
component-familyorg.ajax4jsf.LoadStyle
component-classorg.ajax4jsf.component.html.HtmlLoadStyle
renderer-typeorg.ajax4jsf.LoadStyleRenderer

6.20.2. Creating on a page

Simple Component definition on a page:

Example:


<a4j:loadStyle src="styles/style.css"/>

6.20.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.HtmlLoadStyle;
...
HtmlLoadScript myStyle = new HtmlLoadStyle();
...

6.20.4. Key attributes and ways of usage

As it was mentioned above this component returns its value passing it to the getResourceUR() method of the ViewHandler for this application, and passing the result via the encodeResourceURL() method of the ExternalContext.

It means that the Context will be inserts automatically to the link. And calls like resource:// will be properly handled.

Except this - you may be free to put your stylesheet links right from the child page while using facelets templates.

6.21.  < a4j:poll >

6.21.1. Description

The <a4j:poll> component allows periodical sending of Ajax requests to the server and is used for a page update according to a specified in milliseconds time interval.

Table 6.40. a4j : poll attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression.
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
enabledEnable/disable polling
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
intervalInterval (in ms) for call poll requests. Default value 1000 (1 sec)
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
onsubmitJavaScript code for call before submission of ajax event
renderedIf "false", this component is not rendered
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutTimeout (in ms) for request

Table 6.41. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Poll
component-familyorg.ajax4jsf.components.AjaxPoll
component-classorg.ajax4jsf.component.html.AjaxPoll
renderer-typeorg.ajax4jsf.components.AjaxPollRenderer

6.21.2. Creating on a page

To use this component it's necessary only to set an update interval.

Example:


<a4j:poll interval="1000" reRender="someDataTable" action="#{bean.action1}"/>

The <a4j:poll> component defined this way every second submits Ajax form onto the server, performs the corresponding action and renders a components with the "someDataTable" id after a response comes back.

6.21.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.AjaxPoll;
...
AjaxPoll myPoll = new AjaxPoll();
...

6.21.4. Key attributes and ways of usage

The component decodes all necessary JavaScript for time count and on the expiry of some interval for calling of a RichFaces utility method for Ajax request sending (A4J.AJAX.Submit (Some request parameters)).

The timer could be stopped or started in any time. The current state is controlled on the component with the "enabled" attribute:


<a4j:poll interval="1000" enabled="#{bean.boolProperty}"/>

As any RichFaces Action component, <a4j:poll> has all described in the <a4j:support> chapter attributes to provide the necessary behavior of request sending (delay, limitation of a submit and render area, requests frequency, and etc.). For detailed information on these attributes see again the <a4j:support> component description.

6.21.5. Relevant resources links

Here you can see the example of <a4j:poll> usage and sources for the given example.

The aditional information about component usage you can find here : RichFaces Users Forum.

6.22.  < a4j:page >

6.22.1. Description

<a4j:page> is a deprecated component used for solving of incompatibility problems in early Ajax4jsf and MyFaces versions. The component encodes the full html page structure.

Table 6.42. a4j : page attributes

Attribute NameDescription
ajaxListenerMethodBinding representing an action listener method that will be notified when this component is activated by the ajax Request and handle it. The expression must evaluate to a public method that takes an AjaxEvent parameter, with a return type of void
bindingThe attribute takes a value-binding expression for a component property of a backing bean
contentTypeSet custom mime content type to response
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
formatPage layout format ( html, xhtml, html-transitional, html-3.2 ) for encoding DOCTYPE, namespace and Content-Type definitions
idEvery component may have a unique id that is automatically created if omitted
immediateFlag indicating that, if this component is activated by ajaxrequest, notifications should be delivered to interested listeners and actions immediately (that is, during Apply Request Values phase) rather than waiting until Invoke Application phase
langCode describing the language used in the generated markup for this component
namespaceSet html element default namespace
onloadJavaScript code to execute on a page load.
onunloadJavaScript code to execute on a page unload.
pageTitleString for output as a page title.
renderedIf "false", this component is not rendered
selfRenderedif "true", self-render subtree at InvokeApplication ( or Decode, if immediate property set to true ) phase
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component

Table 6.43. Component identification parameters

NameValue
component-typeorg.ajax4jsf.components.Page
component-familyorg.ajax4jsf.components.AjaxRegion
component-classorg.ajax4jsf.component.html.HtmlPage
renderer-typeorg.ajax4jsf.components.AjaxPageRenderer

6.22.2. Creating on a page

This component should be defined as a child component for <f:view>:


<f:view>
 <a4j:page>
  <f:facet name="head">
   <!--...Head Content here-->
  </f:facet>
   <!--...Page Content here-->
 </a4j:page>
</f:view>

This structure is rendered as:

Example:


<HTML>
 <HEAD> 
 <!--...Head Content here-->
 </HEAD> 
<body >
 <!--...Page Content Here-->
</body> 
</HTML>

6.22.3. Dynamical creation of a component from Java code

Example:


import org.ajax4jsf.component.html.HtmlPage;
...
HtmlPage myPage = new HtmlPage();
...

6.22.4. Key attributes and ways of usage

The component is mostly used to solve the following problem with MyFaces for erlier Ajax4jsf versions: in MyFaces <f:view> doesn't get control over the " RENDER_RESPONSE " phase, thus Ajax can't get control and make a response also. To avoid this problem it was necessary to use <a4j:page> on a page round the Ajax updatable area. In the last versions of both frameworks the problem is successfully fixed and no <a4j:page> usage is required.

The component is rendered as a full HTML page template (it was shown in the example). The " head " section is defined with the help of the corresponding facet with the name="head" and also there is an attribute with the same name for "contentType" definition.

6.22.5. Relevant resources links

Here you can see the example of <a4j:page> usage and sources for the given example.

6.23.  < a4j:include >

6.23.1. Description

The <a4j:include> component is used for page areas update after an Ajax request according to the faces-config Navigation Rules and for implementation of wizard-like parts work in Ajax mode.

Table 6.44. a4j : include attributes

Attribute NameDescription
ajaxRenderedDefines, whether the content of this component must be (or not) included in AJAX response created by parent AJAX Container, even if it is not forced by reRender list of ajax action. Ignored if component marked to output by Ajax action. default false
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
idEvery component may have a unique id that is automatically created if omitted
keepTransientFlag for mark all child components to non-transient. If true, all children components will be set to non-transient state and keep in saved components tree. For output in self-renderer region all content ( By default, all content in <f:verbatim> tags and non-jsf elements in facelets, marked as transient - since, self-rendered ajax regions don't plain output for ajax processing ).
langCode describing the language used in the generated markup for this component
layoutHTML layout for generated markup. Possible values: "block" for generating an HTML <div> element, "inline" for generating an HTML <span> element, and "none" for generating no HTML element. There is a minor exception for the "none" case where a child element has the property "rendered" set to "false". In this case, we create an empty <span> element with same ID as the child element to use as a placeholder for later processing.
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
viewIdviewId for included page.

Table 6.45. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Include
component-familyjavax.faces.Output
component-classorg.ajax4jsf.component.html.Include
renderer-typeorg.ajax4jsf.components.AjaxIncludeRenderer


6.23.2. Creating on a page

To use the component, it's necessary to place the following strings on a page:

Example:


<h:panelGroup id="wizard">
        <a4j:include  viewId="/pages/include/first.xhtml" />
</h:panelGroup>

For navigation inside a page defined in viewId any components responsible for Ajax requests to the server generation are used.

For example, the following component on a page "/pages/include/first.xhtml"

Example:


...
<a4j:commandButton action="next" reRender="wizard"/>
...

And in faces-config it's defined:

Example:


<navigation-rule>
  <from-view-id>/pages/include/first.xhtml</from-view-id>
  <navigation-case>
   <from-outcome>next</from-outcome>
   <to-view-id>/pages/include/second.xhtml</to-view-id>
  </navigation-case>
 </navigation-rule>

In this case after a click on a button defined inside "first.xhtml" view, navigation is performed after an Ajax request (the same as standard JSF one) only inside this view.

6.23.3. Dynamical creation of a component from Java code


<import org.ajax4jsf.component.html.Include;
...
Include myInclude = new Include();
...

If <a4j:include> is defined this way, any Ajax request returning outcome inside generates navigation with this <a4j:include> .

Ajax Action for navigation implementation inside view must be placed inside <a4j:include> pages. Navigation defined by these pages is applied to the <a4j:include> element current for them.

As in the general case for Ajax Action component, if the <a4j:action> component inside <a4j:include> returns outcome defined as <redirect/>, Ajax submit is performed with navigation of the whole page and not only of the current view.

6.23.4. Relevant resources links

Here you can see the example of <a4j:include> usage and sources for the given example.

Some additional information can be found on the Ajax4Jsf Users Forum.

6.24.  < rich:calendar >

6.24.1. Description

The <rich:calendar> component is used for creating monthly calendar elements on a page.

6.24.2. Key Features

  • Highly customizable look and feel
  • Popup representation
  • Disablement support
  • Smart and user-defined positioning
  • Cells customization
  • Macro substitution based on tool bars customization

Table 6.46. rich : calendar attributes

Attribute NameDescription
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
boundaryDatesModeUsed for the dates boundaries in the list. Valid values are "inactive" (Default) – dates inactive and gray colored, "scroll" – boundaries work as month scrolling controls, and "select" – boundaries work in the same way as "scroll" but with the date clicked selection
buttonClassStyle Class attribute for the popup button
buttonIconDefines icon for the popup button element. The attribute is ignored if the "buttonLabel" is set
buttonIconDisabledDefines disabled icon for the popup button element. The attribute is ignored if the "buttonLabel" is set
buttonLabelDefines label for the popup button element. If the attribute is set "buttonIcon" and "buttonIconDisabled" are ignored
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
currentDateDefines current date
currentDateChangeListenerMethodBinding representing an action listener method that will be notified after date selection
dataModelUsed to provide data for calendar elements. If data is not provided, all Data Model related functions are disabled
datePatternDefines date pattern
directionDefines direction of the calendar popup (top-left, top-right, bottom-left, bottom-right (Default), auto)
disabledIf "true", rendered is disabled. In "popup" mode both controls are disabled
enableManualInputIf "true" calendar input will be editable and it will be possible to change the date manualy. If "false" value for this attribute makes a text field "read-only", so the value can be changed only from a handle
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
heightDefines a height of the calendar
horizontalOffsetSets the horizontal offset between button and calendar element conjunction point
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inputClassStyle Class attribute for the text field
inputStyleStyle attribute for text field
jointPointSet the corner of the button for the popup to be connected with (top-left, top-right, bottom-left (Default), bottom-right, auto)
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
localeUsed for locale definition
modeValid values = ajax or client
monthLabelsAttribute that allows to customize names of the months. Should accept list with the month names
monthLabelsShortAttribute that allows to customize short names of the months. Should accept list with the month names
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncollapseonCollapse event handler
oncompleteJavaScript code for call after request completed on client side
oncurrentdateselectonCurrentDateSelect event handler
ondatemouseoutonDateMouseOut event handler
ondatemouseoveronDateMouseOver event handler
ondateselectonDateSelect event handler
ondateselectedonDateSelected event handler
onexpandonExpand event handler
oninputblurinput onBlur event handler
oninputchangeinput onChange event handler
oninputclickinput onClick event handler
oninputfocusinput onFocus event handler
oninputkeydowninput onKeyDown event handler
oninputkeypressinput onKeyPress event handler
oninputkeyupinput onKeyUp event handler
oninputselectinput onSelect event handler
popupIf "true" calendar will be rendered initially as hidden with additional elements for calling as popup
preloadDateRangeBeginDefine the initial range of date which will be loaded to client from dataModel under rendering
preloadDateRangeEndDefines the last range of date which will be loaded to client from dataModel under rendering
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
showInput"false" value for this attribute makes text field invisible. If "true" - input field will be shown
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
timeZoneUsed for current date calculations
toolTipModeUsed to specify mode to load tooltips. Valid values are "none", "single" and "batch"
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe initial value to set when rendered for the first time
valueChangeListenerListener for value changes
verticalOffsetSets the vertical offset between button and calendar element conjunction point
weekDayLabelsList of the day names displays on the days bar in the following way "Sun, Mon, Tue, Wed, …"
weekDayLabelsShortAttribute that allows to customize short names of the weeks. Should accept list with the weeks names.
widthDefines a width of the calendar
zindexAttribute is similar to the standard HTML attribute and can specify window placement relative to the content

Table 6.47. Component identification parameters

NameValue
component-typeorg.richfaces.Calendar
component-classorg.richfaces.component.html.HtmlCalendar
component-familyorg.richfaces.Calendar
renderer-typeorg.richfaces.CalendarRenderer
tag-classorg.richfaces.taglib.CalendarTag

6.24.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

Example:


...
      <rich:calendar popup="false"/>
...

6.24.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlCalendar;   
...
HtmlCalendar myCalendar = new HtmlCalendar();
...

6.24.5. Details of Usage

The "popup" attribute defines calendar representation mode on a page. If it's "true" the calendar is represented on a page as an input field and a button. Clicking on the button calls the calendar popup as it's shown on the picture below.

Using the "popup" attribute

Figure 6.1. Using the "popup" attribute


There are three button-related attributes:

  • "buttonLabel" defines a label for the button. If the attribute is set "buttonIcon" and "buttonIconDisabled" are ignored

  • "buttonIcon" defines an icon for the button

  • "buttonIconDisabled" defines an icon for the disabled state of the button

The "direction" and "jointPoint" attributes are used for defining aspects of calendar appearance.

The possible values for the "direction" are:

  • top-left - a calendar drops to the top and left
  • top-right - a calendar drops to the top and right
  • bottom-left - a calendar drops to the bottom and left
  • bottom-right - a calendar drops to the bottom and right
  • auto - smart positioning activation

By default, the "direction" attribute is set to "bottom-right".

The possible values for the "jointPoint" are:

  • top-left - a calendar docked to the top-left point of the button element
  • top-right - a calendar docked to the top-right point of the button element
  • bottom-left - a calendar docked to the bottom-left point of the button element
  • bottom-right - a calendar docked to the bottom-right point of the button element
  • auto - smart positioning activation

By default, the "jointPoint" attribute is set to "bottom-left".

The <rich:calendar> component provides to use "header" facet. For example, you can add following scrolling elements to the facet: {currentMonthControl}, {nextMonthControl}, {nextYearControl}, {previousYearControl}, {previousMonthControl}.

Simple example is placed below.

Example:


...
      <f:facet name="header">
            <f:verbatim>
                  {previousMonthControl} | {nextMonthControl}                   
            </f:verbatim>
      </f:facet>
...

It's possible to define "footer" facet and replace in it (in the same way how it was described for "header" facet), for example, following today bar elements: {todayControl}, {selectedDateControl}, {helpControl}.

Also you can use "optionalHeader" and "optionalFooter" facets. These facets define the top and the bottom elements of the calendar. They are not attached to the control parts of the calendar. You can replace in them any content.

The <rich:calendar> component provides the possibility to use "weekNumber" and "weekDay" facets. For example, using these facets you can change text style for the elements of the calendar as it's shown in the example below:

Example:


...
      <f:facet name="weekNumber">
            <h:outputText style="font-weight: bold;" value="{weekNumber}" />
      </f:facet>
...

The example of using JavaScript API is placed below:

Example:


...
         <a4j:form id="form">
                <h:panelGroup id="test" columns="2" style="width: 300px">
                        <h:selectBooleanCheckbox value="#{bean.check}">
                                <a4j:support event="onchange" reRender="test" />
                                <f:selectItem itemValue="true" itemLabel="Show" />
                                <f:selectItem itemValue="false" itemLabel="Hide" />
                        </h:selectBooleanCheckbox>
                        <rich:calendar popup="true"
                                        rendered="#{!bean.check}" value="#{bean.date}" id="c"/>
                                <a onclick="$('form:c').component.doExpand()" href="#">Show</a> 
                </h:panelGroup>
        </a4j:form>
...

Also the discussion about this problem can be found on the RichFaces Users Forum.

The <rich:calendar> component provides the possibility to use a special data model to define data for element rendering. Data model includes two major interfaces:

  • CalendarDataModel
  • CalendarDataModelItem

CalendarDataModel provides the following function:

  • CalendarDataModelItem[] getData(Date[]);

This method is called when it's necessary to represent the next block of CalendarDataItems. It happens during navigation to the next (previous) month or in any other case when calendar renders. This method is called in "Ajax" mode when the calendar renders a new page.

CalendarDataModelItem provides the following function:

  • Date getDate() - returns date from the item. Default implementation returns date.
  • Boolean isEnabled() - returns "true" if date is "selectable" on the calendar. Default implementation returns "true".
  • String getStyleClass() - returns string appended to the style class for the date span. For example it could be "relevant holyday". It means that the class could be defined like the "rich-cal-day-relevant-holyday" one. Default implementation returns empty string.
  • Object getData() - returns any additional payload that must be JSON-serializable object. It could be used in the custom date representation on the calendar (inside the custom facet).

6.24.6. JavaScript API

Table 6.48. JavaScript API

FunctionDescription
selectDate(date)Select the date specified. If the date isn't in current month - performs request to select
isDateEnabled(date)Check if given date is selectable
enableDate(date)Enables date cell control on the calendar
disableDate(date)Disables date cell control on the calendar
enableDates(date[])Enables dates cell controls set on the calendar
disableDates(date[])Disables dates cell controls set on the calendar
nextMonth()Navigate to next month
nextYear()Navigate to next year
prevMonth()Navigate to previous month
prevYear()Navigate to previous year
today()Select today date
getSelectedDate()Return currently selected date
Object getData()Return additional data for the date
enable()enables calendar
disable()disables calendar
getCurrentMonth()Returns number of the month currently being viewed
getCurrentYear()Returns number of the year currently being viewed
doCollapse()Collapse calendar element
doExpand()Expand calendar element

6.24.7. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all <rich:calendar> components at once:

  • Redefine the corresponding skin parameters

  • Add to your style sheets style classes used by a <rich:calendar> component

6.24.8. Skin parameters redefinition

Table 6.49. Skin parameters redefinition for a popup element

Skin parametersCSS properties
panelBorderColorborder-color

Table 6.50. Skin parameters redefinition for headers (header, optional header)

Skin parametersCSS properties
panelBorderColorborder-bottom-color
additionalBackgroundColorbackground-color
generalSizeFontfont-size
generalFamilyFontfont-family

Table 6.51. Skin parameters redefinition for footers (footer, optional footer) and names of working days

Skin parametersCSS properties
panelBorderColorborder-top-color
panelBorderColorborder-right-color
additionalBackgroundColorbackground
generalSizeFontfont-size
generalFamilyFontfont-family

Table 6.52. Skin parameters redefinition for weeks numbers

Skin parametersCSS properties
panelBorderColorborder-bottom-color
panelBorderColorborder-right-color
additionalBackgroundColorbackground
calendarWeekBackgroundColorbackground-color
generalSizeFontfont-size
generalFamilyFontfont-family

Table 6.53. Skin parameters redefinition for a toolbar and names of months

Skin parametersCSS properties
headerBackgroundColorbackground-color
headerSizeFontfont-size
headerFamilyFontfont-family
headerWeightFontfont-weight
headerTextColorcolor

Table 6.54. Skin parameters redefinition for cells with days

Skin parametersCSS properties
panelBorderColorborder-bottom-color
panelBorderColorborder-right-color
generalBackgroundColorbackground-color
generalSizeFontfont-size
generalFamilyFontfont-family

Table 6.55. Skin parameters redefinition for holiday

Skin parametersCSS properties
calendarHolidaysBackgroundColorbackground-color
calendarHolidaysTextColorcolor

Table 6.56. Skin parameters redefinition for cell with a current date

Skin parametersCSS properties
calendarCurrentBackgroundColorbackground-color
calendarCurrentTextColorcolor

Table 6.57. Skin parameters redefinition for a selected day

Skin parametersCSS properties
headerBackgroundColorbackground-color
headerTextColorcolor
headerWeightFontfont-weight

6.24.9. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Style classes

Figure 6.2. Style classes


Table 6.58. Classes names that define an input field and a button appearance

Class nameDescription
rich-calendar-input Defines styles for an input field
rich-calendar-buttonDefines styles for a popup button

Table 6.59. Classes names that define a days appearance

Class nameDescription
rich-calendar-daysDefines styles for names of working days in a header
rich-calendar-weekendsDefines styles for names of weekend in a header
rich-calendar-weekDefines styles for weeks numbers
rich-calendar-todayDefines styles for cell with a current date
rich-calendar-cellDefines styles for cells with days
rich-calendar-hollyDefines styles for holiday
rich-calendar-selectDefines styles for a selected day
rich-calendar-hoverDefines styles for a hovered day

Table 6.60. Classes names that define a popup element

Class nameDescription
rich-calendar-exteriorDefines styles for a popup element
rich-calendar-toolDefines styles for toolbars
rich-calendar-monthDefines styles for names of months
rich-calendar-header-optionalDefines styles for an optional header
rich-calendar-footer-optionalDefines styles for an optional footer
rich-calendar-headerDefines styles for a header
rich-calendar-footerDefines styles for a footer
rich-calendar-boundary-datesDefines styles for an active boundary button
rich-calendar-btnDefines styles for an inactive boundary date
rich-calendar-currentDefines styles for a today control date

In order to redefine the style for all <rich:calendar> components on a page using CSS, it's enough to create classes with the same names and define the necessary properties in them.

To change the style of particular <rich:calendar> components define your own style classes in the corresponding <rich:calendar> attributes.

6.24.10. Relevant resources links

Here you can see the example of <rich:calendar> usage and sources for the given example.

How to use JavaScript API see on the RichFaces Users Forum.

6.25.  < rich:dataFilterSlider >

6.25.1. Description

A slider-based action component is used for filtering table data.

DataFilterSlider component

Figure 6.3. DataFilterSlider component


6.25.2. Key Features

  • Filter any UIData based component in dependency on its child's values
  • Fully skinnable control and input elements
  • Optional value text field with an attribute-managed position
  • Optional disablement of the component on a page
  • Optional ToolTip to display the current value while a handle is dragged
  • Dragged state is stable after the mouse moves
  • Optional manual input possible if a text input field is present
  • Validation of manual input

Table 6.61. rich : dataFilterSlider attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
endRangeA slider end point
fieldStyleClassThe styleClass for input that displays the value : 'manualInput' must be true
filterByA getter of an object member required to compare a slider value to. This is a value that is used in results filtering
forThe component using UIData (datatable id)
forValRefThis is a string which is used in a value attribute of the datatable. It is used for resetting the datatable back to the original list provided by a backing bean
handleStyleClassThe handleStyleClass for a handle
handleValueCurrent handle value
idEvery component may have a unique id that is automatically created if omitted
incrementAmount to which a handle on each slide/move should be incremented
manualInputFalse value for this attribute makes text field "read-only" and "hidden". Hence, the value can be changed only from a handle
onChangeIf the slider value changes must submit a form, onSlide or OnChange can be true
onSlideIf the slider value changes must submit a form, onSlide or OnChange can be true
rangeStyleClassThe rangeStyleClass for the background div showing a full range
renderedIf "false", this component is not rendered
sliderListenerMethodBinding representing an action listener method that will be notified after changing of slider control position
startRangeA slider begin point
storeResultsSpecifies if the component will store a UIData object (your table rows) in session
styleCSS style(s) is/are to be applied when this component is rendered
styleClassThe styleClass for the container div surrounding the component
trackStyleClassThe trackStyleClass for a background div
trailerIt shows or hides a trailer following a handle
trailerStyleClassThe trailerStyleClass for a div following a handle
widthWidth of the slider control

Table 6.62. Component identification parameters

NameValue
component-typeorg.richfaces.dataFilterSlider
component-classorg.richfaces.component.html.HtmlDataFilterSlider
component-familyorg.richfaces.DataFilterSlider
renderer-typeorg.richfaces.DataFilterSliderRenderer
tag-classorg.richfaces.taglib.dataFilterSliderTag

6.25.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:dataFilterSlider sliderListener="#{mybean.doSlide}"
                        startRange="0"
                        endRange="50000"
                        increment="10000"
                        handleValue="1"
    />
...

6.25.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlDataFilterSlider;   
...
HtmlDataFilterSlider mySlider = new HtmlDataFilterSlider();
...

6.25.5. Details of Usage

The dataFilterSlider component is bound to some UIData component using a "for" attribute and filters data in this table.

Example:


...
    <rich:dataFilterSlider sliderListener="#{mybean.doSlide}"
                        startRange="0"
                        endRange="50000"
                        increment="10000"
                        handleValue="1"
                        for="carIndex"
                        forValRef="inventoryList.carInventory" 
                        filterBy="getMileage"
    />
...
    <h:dataTable id="carIndex"> 
        ... 
    </h:dataTable>
...

In this example other two attributes are used for filtering:

  • "forValRef" is a string which is used in a value attribute of the target UIData component. It's designed for resetting the UIData component back to the original list provided by a backing bean.
  • "filterBy" is a getter of an object member that is to be compared to a slider value. It's a value that is used in results filtering.

"handleValue" is an attribute for keeping the current handler position on the dataFilterSlider component. Based on the current value, appropriate values obtained from a getter method defined in "filterBy" are filtered.

One more important attribute is a "storeResults" one that allows the dataFilterSlider component to keep UIData target object in session.

If it's necessary the component submits a form on event of a handler state changing, use the "onSlide" attribute ( "onChange" is its alias). When the attribute definition = true, submission on this event is defined.

6.25.6. Relevant resources links

Here you can see the example of <rich:dataFilterSlider> usage and sources for the given example.

6.26.  < rich:datascroller >

6.26.1. Description

The component designed for providing the functionality of tables scrolling using Ajax requests.

Datascroller component

Figure 6.4. Datascroller component


6.26.2. Key Features

  • Provides table scrolling functionality

  • Built-in Ajax processing

  • Provides fast controls

  • Skin support

Table 6.63. rich : datascroller attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleIf "true", submits ONLY one field/link, instead of all form controls
alignleft|center|right [CI] Deprecated. This attribute specifies the position of the table with respect to the document. Permitted values: * left: The table is to the left of the document. * center: The table is to the center of the document. * right: The table is to the right of the document
bindingThe attribute takes a value-binding expression for a component property of a backing bean
boundaryControlsPossible values are: "show" - default mode. Controls are visible always. "hide" - controls are hidden. "auto" - unnecessary controls are hidden
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
fastControlsPossible values are: "show" - default mode. Controls are visible always. "hide" - controls are hidden. "auto" - unnecessary controls are hidden
fastStepThe attribute indicates pages quantity to switch onto when fast scrolling is used
focusid of element to set focus after request completed on client side
forID of the table component whose data is scrollled
handleValueCurrent handle value
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inactiveStyleCorresponds to the HTML style attribute for the inactive cell on scroller
inactiveStyleClassCorresponds to the HTML class attribute for the inactive cell on scroller
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
maxPagesMaximum quantity of pages
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
pageIndexVarName of variable in request scope containing index of active page
pagesVarName of variable in request scope containing number of pages
renderedIf "false", this component is not rendered
renderIfSinglePageIf renderIfSinglePage=true then datascroller is displayed on condition that the data hold on one page
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
scrollerListenerMethodBinding representing an action listener method that will be notified after scrolling
selectedStyleCorresponds to the HTML style attribute for the selected cell on scroller
selectedStyleClassCorresponds to the HTML class attribute for the selected cell on scroller
statusID (in format of call UIComponent.findComponent()) of Request status component
stepControlsPossible values are: "show" - default mode. Controls are visible always. "hide" - controls are hidden. "auto" - unnecessary controls are hidden
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tableStyleCSS style(s) is/are to be applied to outside table when this component is rendered
tableStyleClassSpace-separated list of CSS style class(es) that are be applied to outside table of this component
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component

Table 6.64. Component identification parameters

NameValue
component-typeorg.richfaces.Datascroller
component-classorg.richfaces.component.html.HtmlDatascroller
component-familyorg.richfaces.Datascroller
renderer-typeorg.richfaces.DataScrollerRenderer
tag-classorg.richfaces.taglib.DatascrollerTag

6.26.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <h:dataTable id="table">
        ...
    </h:dataTable>
    ...
    <rich:datascroller for="table"/>
...

6.26.4. Dynamical creation from Java code

Example:


import org.richfaces.component.html.HtmlDatascroller;
... 
HtmlDatascroller myScroll = new HtmlDatascroller();
...

6.26.5. Details of Usage

The <rich:Datascroller> component provides table scrolling functionalitity the same as tomahawk scroller but with Ajax requests usage.

The component should be placed into footer of the parent table or be bound to it with the "for" attribute.

The table should also have the defined "rows" attribute limiting the quantity of inputted table rows.

The scroller could limit the maximum quantity of rendered links on the table pages with the help of the "maxPages" attribute.

Component provides two controllers groups for switching:

  • Page numbers for switching onto a particular page
  • The controls of fast switching: "first", "last", "next", "previous", "fastforward", "fastrewind"

The controls of fast switching are created adding the facets component with the corresponding name:

Example:


 ...
    <rich:datascroller for="table" maxPages="10">
        <f:facet name="first">
            <h:outputText value="First"/>
        </f:facet>
        <f:facet name="last">
            <h:outputText value="Last"/>
        </f:facet>
    </rich:Datascroller>
...
Datascroller controls

Figure 6.5. Datascroller controls


The screenshot shows one controller from each group.

There are also facets used to create the disabled states: "first_disabled", "last_disabled", "next_disabled", "previous_disabled", "fastforward_disabled", "fastrewind_disabled" .

For the "fastforward"/"fastrewind" controls customization the additional "fastStep" attribute is used. The attribute indicates pages quantity to switch onto when fast scrolling is used.

The "pageIndexVar" and "pagesVar" attributes provide an ability to show the current page and the number of pages in the dataScroller. These attributes are used for definition the names of variables, that will be used in the facet with name "pages". An example can be found below:

Example:


 ...
      <h:form>
            <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5">
                  <rich:column>
                         <h:outputText value="#{cap.name}"></h:outputText>
                  </rich:column>
                  <f:facet name="footer">
                        <rich:datascroller pageIndexVar="pageIndex" pagesVar="pages">
                                <f:facet name="pages">
                                      <h:outputText value="#{pageIndex} / #{pages}"></h:outputText>
                                </f:facet>
                        </rich:datascroller>
                  </f:facet>
            </rich:dataTable>
      </h:form>
...

It's possible to insert optional separators between controls. For this purpose use a "controlSeparator" facet. An example is placed below.


 ...
      <f:facet name="controlSeparator">
            <h:graphicImage value="/image/sep.gif"/>
      </f:facet>
...

6.26.6. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method.

Default style classes are mapped on skin parameters.

To redefine appearance of all dataScrollers at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the dataScroller to your page style sheets

6.26.7. Skin parameters redefinition

Table 6.65. Skin parameters redefinition for a wrapper element

Skin parametersCSS properties
tableBackgroundColorbackground-color
panelBorderColorborder-color

Table 6.66. Skin parameters redefinition for a button

Skin parametersCSS properties
additionalBackgroundColorbackground-color
panelBorderColorborder-color
generalFamilyFontfont-family
generalSizeFontfont-size

Table 6.67. Skin parameters redefinition for an active button

Skin parametersCSS properties
generalTextColorborder-top-color
generalTextColorcolor
generalFamilyFontfont-family
generalSizeFontfont-size

Table 6.68. Skin parameters redefinition for an inactive button

Skin parametersCSS properties
headerBackgroundColorborder-top-color
headerBackgroundColorcolor
generalFamilyFontfont-family
generalSizeFontfont-size

6.26.8. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Style classes

Figure 6.6. Style classes


Table 6.69. Classes names that define a component appearance

Class nameDescription
rich-dtascroller-tableDefines styles for a wrapper table element of the component
rich-datascr-buttonDefines styles for a button

Table 6.70. Classes names that define a buttons appearance

Class nameDescription
rich-datascr-actDefines styles for an active button
rich-datascr-inactDefines styles for an inactive button
rich-datascr-button-dsbldDefines styles for a disabled button

To redefine an appearance of all scrollers on a page, just redefine one of these classes

And to redefine the appearance of the particular scroller, one may use corresponding class attributes on the component.

6.26.9. Relevant resources links

Here you can see the example of <rich:dataScroller> usage and sources for the given example.

The solution about how to do correct pagination using datascroller (load a part of data from database) can be found on the RichFaces Users Forum.

How to use <rich:dataTable> and <rich:dataScroller> in a context of Extended Data Model see here.

6.27.  < rich:subTable >

6.27.1. Description

The component is used for inserting subtables into tables with opportunity to choose data from a model and built-in Ajax updates support.

SubTable element

Figure 6.7. SubTable element


6.27.2. Key Features

  • Completely skinned table rows and child elements
  • Possibility to insert complex columnGroup subcomponents
  • Possibility to combine rows and columns inside
  • Possibility to update a limited set of rows with AJAX

Table 6.71. rich : subTable attributes

Attribute NameDescription
ajaxKeysThis attribute defines rows that are updated after an AJAX request
bindingThe attribute takes a value-binding expression for a component property of a backing bean
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
componentStateIt defines EL-binding for a component state for saving or redefinition
firstA zero-relative row number of the first row to display
footerClassSpace-separated list of CSS style class(es) that are be applied to any footer generated for this table
headerClassSpace-separated list of CSS style class(es) that are be applied to any header generated for this table
idEvery component may have a unique id that is automatically created if omitted
onRowClickHTML: a script expression; a pointer button is clicked on row
onRowDblClickHTML: a script expression; a pointer button is double-clicked on row
onRowMouseDownHTML: script expression; a pointer button is pressed down on row
onRowMouseMoveHTML: a script expression; a pointer is moved within of row
onRowMouseOutHTML: a script expression; a pointer is moved away of row
onRowMouseOverHTML: a script expression; a pointer is moved onto of row
onRowMouseUpHTML: script expression; a pointer button is released on row
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyRowKey is a representation of an identifier for a specific data row
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
sortExpressionsortExpression
stateVarThe attribute provides access to a component state on the client side
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating

Table 6.72. Component identification parameters

NameValue
component-typeorg.richfaces.SubTable
component-classorg.richfaces.component.html.HtmlSubTable
component-familyorg.richfaces.SubTable
renderer-typeorg.richfaces.SubTableRenderer
tag-classorg.richfaces.taglib.SubTableTag

6.27.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="capitals">
        <!--...//Set of columns and header/footer facets-->
        <rich:subTable value=#{capitals.detailsvar="detail">
            <!--...//Set of columns and header/footer facets-->
        </rich:subTable>
    </rich:dataTable>
...

6.27.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlSubTable;
...
HtmlSubTable mySubTable = new HtmlSubTable();
...

6.27.5. Details of Usage

The subtable component is very similar to the custom JSF dataTable one, the only difference is that the component doesn't add the wrapping <table> and <tbody> tags. Hence, it's possible to add a subtable structure different from the main one to organize tables of the master - details type. The component is also has common peculiarities of any rich component:

  • Skin support. The table completely meets a three-class principle of Rich Faces skinnability
  • Support of Ajax updates for a limited set of rows

Skins support is described in the corresponding section. Ajax support is possible because the component is created basing on the <a4j:repeat> component and as a result the component has its possibilities of Ajax updates for a limited set of rows. The component is implemented with the "ajaxKeys" attribute for a table and in contrast to the <a4j:repeat> outputs the standard HTML structure for table rendering.


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="capitals" id="table">
        <!--...//Set of columns and header/footer facets-->
        <rich:subTable value="#{capitals.details}" var="detail" ajaxKeys="#{bean.ajaxSet}" binding="#{bean.subtable}" >
            <!--...//Set of columns and header/footer facets-->
        </rich:subTable>
    </rich:dataTable>
...
    <a4j:commandButton action="#{bean.someAction}" reRender="table"/>
...

For such a table during someAction processing called with Ajax request when the key is pressed it's possible to fill in lot's of ajaxKeys with strings indices that are to be updated. A resulting output on the client contains only required rows and they are updated in the tree, even when update is specified for the whole table.

6.27.6. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all subTables at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the subTable to your page style sheets

To redefine a style of a particular page, use component class attributes which list is the same as the subTable one and is known to you.

6.28.  < rich:column >

6.28.1. Description

The component for row rendering for a UIData component.

Column component

Figure 6.8. Column component


6.28.2. Key Features

  • Completely skinned table rows and child elements
  • Possibility to combine columns with the help of "colspan"
  • Possibility to combine rows with the help of "rowspan" and "breakBefore"

Table 6.73. rich : column attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
breakBeforeif "true" next column begins from the first row
colspanCorresponds to the HTML colspan attribute
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
footerClassSpace-separated list of CSS style class(es) that are be applied to any footer generated for this table
headerClassSpace-separated list of CSS style class(es) that are be applied to any header generated for this table
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
renderedIf "false", this component is not rendered
rowspanCorresponds to the HTML rowspan attribute
sortableBoolean attribute. If "true" it's possible to sort the column content after click on the header. Default value is "true"
sortExpressionAttribute defines a bean property which is used for sorting of a column
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
widthAttribute defines width of column. Default value is "100px".

Table 6.74. Component identification parameters

NameValue
component-typeorg.richfaces.Column
component-classorg.richfaces.component.html.HtmlColumn
component-familyorg.richfaces.Column
renderer-typeorg.richfaces.ColumnRenderer
tag-classorg.richfaces.taglib.ColumnTag

6.28.3. Creating the Component with a Page Tag

To create the simplest variant of column on a page, use the following syntax:

Example:


...
    <rich:dataTable var="set">
        <rich:column>
            <h:outputText value="#{set.property1}"/>
        </rich:column>
        <!--Set of another columns and header/footer facets-->
    </rich:dataTable>
...

6.28.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlColumn;
...
HtmlColumn myColumn = new HtmlColumn();
...

6.28.5. Details of Usage

To output a simple table, the <rich:column> component is used the same way as the standard <h:column> , i.e. the following code on a page is used:

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5"> 
        <rich:column>
            <f:facet name="header">State Flag</f:facet>
            <h:graphicImage value="#{cap.stateFlag}"/>
        </rich:column>
        <rich:column>
            <f:facet name="header">State Name</f:facet>
            <h:outputText value="#{cap.state}"/>
        </rich:column>
        <rich:column >
            <f:facet name="header">State Capital</f:facet>
            <h:outputText value="#{cap.name}"/>
        </rich:column>
        <rich:column>
        <f:facet name="header">Time Zone</f:facet>
            <h:outputText value="#{cap.timeZone}"/>
        </rich:column>
    </rich:dataTable>
...

The result is:

Generated column component

Figure 6.9. Generated column component


Now, in order to group columns with text information into one row in one column with a flag, use the "colspan" attribute, which is similar to an HTML one, specifying that the first column contains 3 columns. In addition, it's necessary to specify that the next column begins from the first row with the help of the "breakBefore" attribute = true.

Example:


...
     <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5"> 
        <rich:column colspan="3">
            <h:graphicImage value="#{cap.stateFlag}"/>
        </rich:column>
        <rich:column breakBefore="true"> 
            <h:outputText value="#{cap.state}"/>
        </rich:column>
        <rich:column >
            <h:outputText value="#{cap.name}"/>
        </rich:column>
        <rich:column>
            <h:outputText value="#{cap.timeZone}"/>
        </rich:column>
    </rich:dataTable>
...

As a result the following structure is rendered:

Column modified with colspan and breakbefore attributes

Figure 6.10. Column modified with colspan and breakbefore attributes


The same way is used for columns grouping with the "rowspan" attribute that is similar to an HTML one responsible for rows quantity definition occupied with the current one. The only thing to add in the example is an instruction to move onto the next row for each next after the second column.

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5"> 
        <rich:column rowspan="3">
            <f:facet name="header">State Flag</f:facet>
            <h:graphicImage value="#{cap.stateFlag}"/>
        </rich:column>
        <rich:column> 
            <f:facet name="header">State Info</f:facet>
            <h:outputText value="#{cap.state}"/>
        </rich:column>
        <rich:column breakBefore="true">
            <h:outputText value="#{cap.name}"/>
        </rich:column>
        <rich:column breakBefore="true">
            <h:outputText value="#{cap.timeZone}"/>
        </rich:column>
    </rich:dataTable>
...

As a result:

Column generated with rowspan attribute

Figure 6.11. Column generated with rowspan attribute


Hence, additionally to a standard output of a particular row provided with the <h:column> component, it becomes possible to group easily the rows with special HTML attribute.

The columns also could be grouped in a particular way with the help of the <h:columnGroup> component that is described in the following chapter.

6.28.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all columns at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the column to your page style sheets

6.28.7. Definition Custom Style Classes

To redefine an appearance of all columns on a page, redefine the corresponding class in the CSS file used with the page.

To redefine a style of a particular page, use component class attributes which list is the same as the column one and is known to you.

6.28.8. Relevant resources links

Here you can see the example of <rich:column> usage and sources for the given example.

6.29.  < rich:dataList >

6.29.1. Description

The component for unordered lists rendering that allows choosing data from a model and obtains built-in support of Ajax updates.

DataList component

Figure 6.12. DataList component


6.29.2. Key Features

  • A completely skinned list and child elements
  • Possibility to update a limited set of rows with AJAX
  • Possibility to receive values dynamically from a model

Table 6.75. rich : dataList attributes

Attribute NameDescription
ajaxKeysThis attribute defines rows that are updated after an AJAX request
bindingThe attribute takes a value-binding expression for a component property of a backing bean
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
componentStateIt defines EL-binding for a component state for saving or redefinition
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
firstA zero-relative row number of the first row to display
footerClassSpace-separated list of CSS style class(es) that are be applied to any footer generated for this table
headerClassSpace-separated list of CSS style class(es) that are be applied to any header generated for this table
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyRowKey is a representation of an identifier for a specific data row
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
stateVarThe attribute provides access to a component state on the client side
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
typeCorresponds to the HTML DL type attribute
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating

Table 6.76. Component identification parameters

NameValue
component-typeorg.richfaces.DataList
component-classorg.richfaces.component.html.HtmlDataList
component-familyorg.richfaces.DataList
renderer-typeorg.richfaces.DataListRenderer
tag-classorg.richfaces.taglib.DataListTag

6.29.3. Creating the Component with a Page Tag

To create the simplest variant of dataList on a page, use the following syntax:

Example:


...
    <rich:dataList value="#{bean.capitals}" var="caps">
        <h:outputText value="#{caps.name}"/>
    </rich:dataList>
...

6.29.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlDataList;
...
HtmlDataList myList = new HtmlDataList();
...

6.29.5. Details of Usage

The component takes a list from a model and outputs it as an ordered list. The component also has similar to ordinary UIData components output ways:

  • A header and footer output
  • Limitation of the output elements (the "elements" attribute) and definition of the first element
  • Binding to scrolling components of list pages

The component has the "type" attribute corresponding to the "ul" HTML element.

The component is created basing on the <a4j:repeat> component and as a result the component could be partially updated with AJAX.

Example:


...
    <rich:dataList value="#{bean.capitals}" var="caps" ajaxKeys="#{listBean.list}" 
                        binding="#{listBean.dataList}" id="list">
        <h:outputText value="#{caps.name}"/>
    </rich:dataList>
...
    <a4j:commandButton action"#{listBean.action}" reRender="list" value="Submit">
...

Here during the action is processed the ajaxKeys set is composed into a list and then update specified for the whole table actually happens only for the chosen set of rows.

6.29.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all dataLists at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the dataList to your page style sheets

6.29.7. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Style classes

Figure 6.13. Style classes


Table 6.77. Classes names that define a list appearance

Class nameDescription
rich-datalistDefines styles for an html <ul> element
rich-list-itemDefines styles for an html <li> element

To redefine an appearance of all dataLists on a page, just redefine one of this classes.

To redefine a style of a particular dataList, use corresponding class attributes on the component.

6.29.8. Relevant resources links

Here you can see the example of <rich:dataList> usage and sources for the given example.

6.30.  < rich:dataOrderedList >

6.30.1. Description

The component for ordered lists rendering that allows choosing data from a model and obtains built-in support of Ajax updates.

DataOrderedList component

Figure 6.14. DataOrderedList component


6.30.2. Key Features

  • A completely skinned list and child elements
  • Possibility to update a limited set of rows with AJAX
  • Possibility to receive values dynamically from a model

Table 6.78. rich : dataOrderedList attributes

Attribute NameDescription
ajaxKeysThis attribute defines rows that are updated after an AJAX request
bindingThe attribute takes a value-binding expression for a component property of a backing bean
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
componentStateIt defines EL-binding for a component state for saving or redefinition
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
firstA zero-relative row number of the first row to display
footerClassSpace-separated list of CSS style class(es) that are be applied to any footer generated for this table
headerClassSpace-separated list of CSS style class(es) that are be applied to any header generated for this table
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyRowKey is a representation of an identifier for a specific data row
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
stateVarThe attribute provides access to a component state on the client side
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
typeCorresponds to the HTML OL type attribute
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating

Table 6.79. Component identification parameters

NameValue
component-typeorg.richfaces.DataOrderedList
component-classorg.richfaces.component.html.HtmlDataOrderedList
component-familyorg.richfaces.DataOrderedList
renderer-typeorg.richfaces.DataOrderedListRenderer
tag-classorg.richfaces.taglib.DataOrderedListTag

6.30.3. Creating the Component with a Page Tag

To create the simplest variant of dataOrderedList on a page, use the following syntax:

Example:


...
    <rich:dataOrderedList value="#{bean.capitals}" var="caps">
        <h:outputText value="#{caps.name}"/>
    </rich:dataOrderedList>
...

6.30.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlDataOrderedList; 
...  
HtmlDataOrderedList myList = new HtmlDataOrderedList();
...

6.30.5. Details of Usage

The component takes a list from a model and outputs it as an ordered list. The component also has similar to ordinary UIData components output ways:

  • Header and footer output
  • Limitation of the output elements (the "elements" attribute) and definition of the first element
  • Binding to scrolling components of list pages

The component has the "type" attribute corresponding to the "ul" HTML element.

The component is created basing on the <a4j:repeat> component and as a result the component could be partially updated with AJAX.

Example:


...
    <rich:dataOrderedList value="#{bean.capitals}" var="caps" ajaxKeys="#{listBean.list}" 
                        binding="#{listBean.dataList}" id="list">
        <h:outputText value="#{caps.name}"/>
    </rich:dataOrderedList>
...
    <a4j:commandButton action"#{listBean.action}" reRender="list" value="Submit">
...

Here during the action is processed the ajaxKeys set is composed into a list and then update specified for the whole table actually happens only for the chosen set of rows.

6.30.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all dataOrderedLists at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the dataOrderedList to your page style sheets

6.30.7. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Style classes

Figure 6.15. Style classes


Table 6.80. Classes names that define a list appearance

Class nameDescription
rich-orderedlistDefines styles for an html <ol> element
rich-list-itemDefines styles for an html <li> element

To redefine an appearance of all dataOrderedLists on a page,just redefine one of this classes.

To redefine a style of a particular dataOrderedList, use corresponding class attributes on the component.

6.30.8. Relevant resources links

Here you can see the example of <rich:dataOrderedList > usage and sources for the given example.

6.31.  < rich:dataDefinitionList >

6.31.1. Description

The component for definition lists rendering that allows choosing data from a model and obtains built-in support of Ajax updates.

DataDefinitionList component

Figure 6.16. DataDefinitionList component


6.31.2. Key Features

  • Completely skinned table rows and child elements
  • Possibility to update a limited set of rows with AJAX
  • Possibility to receive values dynamically from a model

Table 6.81. rich : dataDefinitionList attributes

Attribute NameDescription
ajaxKeysThis attribute defines rows that are updated after an AJAX request
bindingThe attribute takes a value-binding expression for a component property of a backing bean
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
componentStateIt defines EL-binding for a component state for saving or redefinition
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
firstA zero-relative row number of the first row to display
footerClassSpace-separated list of CSS style class(es) that are be applied to any footer generated for this table
headerClassSpace-separated list of CSS style class(es) that are be applied to any header generated for this table
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyRowKey is a representation of an identifier for a specific data row
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
stateVarThe attribute provides access to a component state on the client side
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating

Table 6.82. Component identification parameters

NameValue
component-typeorg.richfaces.DataDefinitionList
component-classorg.richfaces.component.html.HtmlDataDefinitionList
component-familyorg.richfaces.DataDefinitionList
renderer-typeorg.richfaces.DataDefinitionListRenderer
tag-classorg.richfaces.taglib.DataDefinitionListTag

6.31.3. Creating the Component with a Page Tag

To create the simplest variant of dataDefinitionList on a page, use the following syntax:

Example:


...
    <rich:dataDefinitionList value="#{bean.capitals}" var="caps">
        <f:facet name="term">United States Capitals</f:facet>
        <h:outputText value="#{caps.name}"/>
    </rich:dataDefinitionList>
...

6.31.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlDataDefinitionList;
...
HtmlDataDefinitionList myList = new HtmlDataDefinitionList();
...

6.31.5. Details of Usage

The component takes a list from a model and outputs it as an ordered list. The component also has similar to ordinary UIData components output ways:

  • A header and footer output
  • Limitation of the output elements (the "elements" attribute) and definition of the first element
  • Binding to scrolling components of list pages

It allows definition inside a facet with the "term" name to add HTML DT elements into a list.

The component is created basing on the <a4j:repeat> component and as a result the component could be partially updated with AJAX.

Example:


...
    <rich:dataDefinitionList value="#{bean.capitals}" var="caps" ajaxKeys="#{listBean.list}" 
                        binding="#{listBean.dataList}" id="list">
        <h:outputText value="#{caps.name}"/>
    </rich:dataDefinitionList>
...
    <a4j:commandButton action"#{listBean.action}" reRender="list" value="Submit"/>
...

Here during the action is processed the ajaxKeys set is composed into a list and then update specified for the whole table actually happens only for the chosen set of rows.

6.31.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all dataDefinitionList at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the dataDefinitionList to your page style sheets

6.31.7. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Style classes

Figure 6.17. Style classes


Table 6.83. Classes names that define a list appearance

Class nameDescription
rich-deflistDefines styles for an html <dl> element
rich-definitionDefines styles for an html <dd> element
rich-definition-termDefines styles for an html <dt> element

To redefine an appearance of all dataDefinitionLists on a page, just redefine one of this classes.

To redefine a style of a particular dataDefinitionList, use corresponding class attributes on the component.

6.31.8. Relevant resources links

Here you can see the example of <rich:dataDefinitionList> usage and sources for the given example.

6.32.  < rich:dataGrid >

6.32.1. Description

The component to render data as a grid that allows choosing data from a model and obtains built-in support of Ajax updates.

DataGrid component

Figure 6.18. DataGrid component


6.32.2. Key Features

  • A completely skinned table and child elements
  • Possibility to update a limited set of rows with AJAX
  • Possibility to receive values dynamically from a model

Table 6.84. rich : dataGrid attributes

Attribute NameDescription
ajaxKeysThis attribute defines rows that are updated after an AJAX request
alignleft|center|right [CI] Deprecated. This attribute specifies the position of the table with respect to the document. Permitted values: * left: The table is to the left of the document. * center: The table is to the center of the document. * right: The table is to the right of the document
bgcolorDeprecated. This attribute sets the background color for the document body or table cells. This attribute sets the background color of the canvas for the document body (the BODY element) or for tables (the TABLE, TR, TH, and TD elements). Additional attributes for specifying text color can be used with the BODY element. This attribute has been deprecated in favor of style sheets for specifying background color information
bindingThe attribute takes a value-binding expression for a component property of a backing bean
borderThis attributes specifies the width of the frame around a component
captionClassSpace-separated list of CSS style class(es) that are be applied to caption for this component
captionStyleCSS style(s) is/are to be applied to caption when this component is rendered
cellpaddingThis attribute specifies the amount of space between the border of the cell and its contents
cellspacingThis attribute specifies the amount of space between the border of the cell and its contents. The attribute also specifies the amount of space to leave between cells
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
columnsQuantity of columns
componentStateIt defines EL-binding for a component state for saving or redefinition
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
elementsNumber of elements in grid
firstA zero-relative row number of the first row to display
footerClassSpace-separated list of CSS style class(es) that are be applied to footer for this component
framevoid|above|below|hsides|lhs|rhs|vsides|box|border [CI] This attribute specifies which sides of the frame surrounding a table will be visible. Possible values: * void: No sides. This is the default value. * above: The top side only. * below: The bottom side only. * hsides: The top and bottom sides only. * vsides: The right and left sides only. * lhs: The left-hand side only. * rhs: The right-hand side only. * box: All four sides. * border: All four sides
headerClassSpace-separated list of CSS style class(es) that are be applied to header for this component
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
onRowClickHTML: a script expression; a pointer button is clicked on row
onRowDblClickHTML: a script expression; a pointer button is double-clicked on row
onRowMouseDownHTML: script expression; a pointer button is pressed down on row
onRowMouseMoveHTML: a script expression; a pointer is moved within of row
onRowMouseOutHTML: a script expression; a pointer is moved away of row
onRowMouseOverHTML: a script expression; a pointer is moved onto of row
onRowMouseUpHTML: script expression; a pointer button is released on row
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyRowKey is a representation of an identifier for a specific data row
rowKeyVarThe attribute provides access to a row key in a Request scope
rulesThis attribute specifies which rules will appear between cells within a table. The rendering of rules is user agent dependent. Possible values: * none: No rules. This is the default value. * groups: Rules will appear between row groups (see THEAD, TFOOT, and TBODY) and column groups (see COLGROUP and COL) only. * rows: Rules will appear between rows only. * cols: Rules will appear between columns only. * all: Rules will appear between all rows and columns
stateVarThe attribute provides access to a component state on the client side
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
summaryThis attribute provides a summary of the table's purpose and structure for user agents rendering to non-visual media such as speech and Braille
titleAdvisory title information about markup elements generated for this component
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating
widthThis attribute specifies the desired width of the entire table and is intended for visual user agents. When the value is percentage value, the value is relative to the user agent's available horizontal space. In the absence of any width specification, table width is determined by the user agent

Table 6.85. Component identification parameters

NameValue
component-typeorg.richfaces.DataGrid
component-classorg.richfaces.component.html.HtmlDataGrid
component-familyorg.richfaces.DataGrid
renderer-typeorg.richfaces.DataGridRenderer
tag-classorg.richfaces.taglib.DataGridTag

6.32.3. Creating the Component with a Page Tag

To create the simplest variant of dataGrid on a page, use the following syntax:

Example:


...
    <rich:dataGrid value="#{bean.capitals}" var="caps" columns="4">
        <h:outputText value="#{caps.name}"/>
    </rich:dataGrid>
...

6.32.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlDataGrid;
...
HtmlDataGrid myList = new HtmlDataGrid();
...

6.32.5. Details of Usage

The component takes a list from a model and outputs it the same way as with <h:PanelGrid> for inline data. To define grid properties and styles, use the same definitions as for <h:panelGrid>. The component also has similar to ordinary UIData components output ways.

  • A header and footer output
  • Limitation of the output elements (the "elements" attribute) and definition of the first element
  • Binding to scrolling components of list pages

The component is created basing on the <a4j:repeat> component and as a result the component could be partially updated with AJAX.

Here is an example for the first screenshot:

Example:


...
    <rich:dataGrid value="#{bean.capitals}" var="caps" ajaxKeys="#{listBean.list}" 
                        binding="#{listBean.dataList}" id="grid" elements="20" columns="4">
        <h:graphicImage value="#{cap.stateFlag}"/>
        <h:outputText value="#{cap.name}"/>
        <h:outputText value="#{cap.state}"/>
        <h:outputText value="#{cap.timeZone}"/>
    </rich:dataGrid>
...
    <a4j:commandButton action"#{listBean.action}" reRender="grid" value="Submit"/>
...

In the example there is an output of a grid with four columns and output limitation to 20 elements. But when the action is processed the ajaxKeys set is composed and then update specified for the whole table actually happens only for the chosen set of elements.

6.32.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all dataGrids at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the dataGrid to your page style sheets

6.32.7. Definition custom style classes

To redefine an appearance of all dataGrids on a page, redefine the corresponding class in the CSS file used with the page.

To redefine a style of a particular table, use "component class" attributes which list is the same as the dataTable one and is known to you.

6.32.8. Relevant resources links

Here you can see the example of <rich:dataGrid> usage and sources for the given example.

6.33.  < rich:dataTable >

6.33.1. Description

The component for tables rendering that allows choosing data from a model and obtains built-in support of Ajax updates.

DataTable component

Figure 6.19. DataTable component


6.33.2. Key Features

  • A completely skinned table and child elements
  • Possibility to insert the complex subcomponents "colGroup" and "subTable"
  • Possibility to update a limited set of strings with AJAX

Table 6.86. rich : dataTable attributes

Attribute NameDescription
ajaxKeysThis attribute defines rows that are updated after an AJAX request
alignleft|center|right [CI] Deprecated. This attribute specifies the position of the table with respect to the document. Permitted values: * left: The table is to the left of the document. * center: The table is to the center of the document. * right: The table is to the right of the document
bgcolorDeprecated. This attribute sets the background color for the document body or table cells. This attribute sets the background color of the canvas for the document body (the BODY element) or for tables (the TABLE, TR, TH, and TD elements). Additional attributes for specifying text color can be used with the BODY element. This attribute has been deprecated in favor of style sheets for specifying background color information
bindingThe attribute takes a value-binding expression for a component property of a backing bean
borderThis attributes specifies the width of the frame around a component
captionClassSpace-separated list of CSS style class(es) that are be applied to caption for this component
captionStyleCSS style(s) is/are to be applied to caption when this component is rendered
cellpaddingThis attribute specifies the amount of space between the border of the cell and its contents
cellspacingThis attribute specifies the amount of space between the border of the cell and its contents. The attribute also specifies the amount of space to leave between cells
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
columnsQuantity of columns
columnsWidthComma-separated list of width attribute for every column. Specifies a default width for each column in the table. In addition to the standard pixel, percentage, and relative values, this attribute allows the special form "0*" (zero asterisk) which means that the width of the each column in the group should be the minimum width necessary to hold the column's contents. This implies that a column's entire contents must be known before its width may be correctly computed. Authors should be aware that specifying "0*" will prevent visual user agents from rendering a table incrementally
componentStateIt defines EL-binding for a component state for saving or redefinition
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
firstA zero-relative row number of the first row to display
footerClassSpace-separated list of CSS style class(es) that are be applied to footer for this component
framevoid|above|below|hsides|lhs|rhs|vsides|box|border [CI] This attribute specifies which sides of the frame surrounding a table will be visible. Possible values: * void: No sides. This is the default value. * above: The top side only. * below: The bottom side only. * hsides: The top and bottom sides only. * vsides: The right and left sides only. * lhs: The left-hand side only. * rhs: The right-hand side only. * box: All four sides. * border: All four sides
headerClassSpace-separated list of CSS style class(es) that are be applied to header for this component
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
onRowClickHTML: a script expression; a pointer button is clicked on row
onRowDblClickHTML: a script expression; a pointer button is double-clicked on row
onRowMouseDownHTML: script expression; a pointer button is pressed down on row
onRowMouseMoveHTML: a script expression; a pointer is moved within of row
onRowMouseOutHTML: a script expression; a pointer is moved away of row
onRowMouseOverHTML: a script expression; a pointer is moved onto of row
onRowMouseUpHTML: script expression; a pointer button is released on row
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyRowKey is a representation of an identifier for a specific data row
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
rulesThis attribute specifies which rules will appear between cells within a table. The rendering of rules is user agent dependent. Possible values: * none: No rules. This is the default value. * groups: Rules will appear between row groups (see THEAD, TFOOT, and TBODY) and column groups (see COLGROUP and COL) only. * rows: Rules will appear between rows only. * cols: Rules will appear between columns only. * all: Rules will appear between all rows and columns
stateVarThe attribute provides access to a component state on the client side
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
summaryThis attribute provides a summary of the table's purpose and structure for user agents rendering to non-visual media such as speech and Braille
titleAdvisory title information about markup elements generated for this component
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating
widthThis attribute specifies the desired width of the entire table and is intended for visual user agents. When the value is percentage value, the value is relative to the user agent's available horizontal space. In the absence of any width specification, table width is determined by the user agent

Table 6.87. Component identification parameters

NameValue
component-typeorg.richfaces.DataTable
component-classorg.richfaces.component.html.HtmlDataTable
component-familyorg.richfaces.DataTable
renderer-typeorg.richfaces.DataTableRenderer
tag-classorg.richfaces.taglib.DataTableTag

6.33.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="capitals">
        <!--...//Set of columns and header/footer facets-->
    </rich:dataTable>
...

6.33.4. Dynamical creation from Java code

Example:


import org.richfaces.component.html.HtmlDataTable;
...
HtmlDataTable myTable = new HtmlDataTable();
...

6.33.5. Details of Usage

The table component is very similar to the custom JSF dataTable one, except for the common peculiarities of any rich component:

  • Skin support. The table completely meets a three-class principle of Rich Faces skinnability
  • Support of Ajax updates for a limited set of strings

Skins support is described in the corresponding section. Ajax support is possible because the component is created basing on the <a4j:repeat> component and as a result the component has its possibilities of Ajax updates for a limited set of strings. The component is implemented with the "ajaxKeys" attribute for a table and in contrast to the <a4j:repeat> outputs the standard HTML structure for table rendering.

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="capitals" 
            ajaxKeys="#{bean.ajaxSet}" binding="#{bean.table}" id="table">
            <!--Set of columns and header/footer facets-->
    </rich:dataTable>
...
    <a4j:commandButton action="#{bean.someAction}" reRender="table"/>
...

For such a table during someAction method processing called with AJAX request when the key is pressed it's possible to fill in lot's of ajaxKeys with strings indices that are to be updated. A resulting output on the client contains only required strings and they are updated in the tree, even when update is specified for the whole table.

6.33.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all dataTables at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the dataTable to your page style sheets

6.33.7. Skin parameters redefinition

Table 6.88. Skin parameters redefinition for a table

Skin parametersCSS properties
tableBackgroundColorbackground-color

Table 6.89. Skin parameters redefinition for a header

Skin parametersCSS properties
headerBackgroundColorbackground-color

Table 6.90. Skin parameters redefinition for a footer

Skin parametersCSS properties
tableFooterBackgroundColorbackground-color

Table 6.91. Skin parameters redefinition for a column header

Skin parametersCSS properties
additionalBackgroundColorbackground-color

Table 6.92. Skin parameters redefinition for a column footer

Skin parametersCSS properties
tableSubfooterBackgroundColorbackground-color

Table 6.93. Skin parameters redefinition for cells

Skin parametersCSS properties
generalSizeFontfont-size
generalTextColorcolor
generalFamilyFontfont-family

6.33.8. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

DataTable class names

Figure 6.20. DataTable class names


Table 6.94. Classes names that define a table appearance

Class nameDescription
rich-tableDefines styles for all table
rich-table-captionDefines styles for a "caption" facet element
rich-table-headerDefines styles for a table header row
rich-table-headercellDefines styles for a header cell
rich-table-subheaderDefines styles for a column header
rich-table-subheadercellDefines styles for a column header cell
rich-table-cellDefines styles for a table cell
rich-table-rowDefines styles for a table row
rich-table-subfooterDefines styles for a column footer
rich-table-subfootercellDefines styles for a column footer cell
rich-table-footerDefines styles for a footer row
rich-table-footercellDefines styles for a footer cell

To redefine an appearance of all tables on a page, redefine the corresponding class in the CSS file used with the page.

To redefine a style of a particular page, use "component class" attributes which list is the same as the dataTable one and is known to you.

6.33.9. Relevant resources links

Here you can see the example of <rich:dataTable> usage and sources for the given example.

The article about <rich:dataTable> flexibility can be found here.

More information about using <rich:dataTable> and <rich:subTable> could be found on the RichFaces Users Forum.

How to use <rich:dataTable> and <rich:dataScroller> in a context of Extended Data Model see here.

6.34.  < rich:columnGroup >

6.34.1. Description

The component combines columns in one row to organize complex subparts of a table.

ColumnGroup component

Figure 6.21. ColumnGroup component


6.34.2. Key Features

  • Completely skinned table columns and child elements
  • Possibility to combine columns and rows inside
  • Possibility to update a limited set of strings with Ajax

Table 6.95. rich : columnGroup attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
breakBeforeif "true" next column begins from the first row
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component

Table 6.96. Component identification parameters

NameValue
component-typeorg.richfaces.ColumnGroup
component-classorg.richfaces.component.html.HtmlColumnGroup
component-familyorg.richfaces.ColumnGroup
renderer-typeorg.richfaces.ColumnGroupRenderer
tag-classorg.richfaces.taglib.ColumnGroupTag

6.34.3. Creating the Component with a Page Tag

To create the simplest variant of columnGroup on a page, use the following syntax:

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="capitals" 
                        ajaxKeys="#{bean.ajaxSet}" binding="#{bean.tabe}" id="table">
        <!--...//Set of columns and header/footer facets-->
        <rich:column colspan="3">
            <f:facet name="header">State Flag</f:facet>
            <h:graphicImage value="#{cap.stateFlag}"/>
        </rich:column>
        <rich:columnGroup>
            <!--...//Set of columns and header/footer facets-->
        </rich:columnGroup> 
    </rich:dataTable>
...

6.34.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlColumnGroup;
... 
HtmlColumnGroup myRow = new HtmlColumnGroup();
...

6.34.5. Details of Usage

The <rich:columnGroup> component combines columns set wrapping them into the <tr> element and outputting them into one row. Columns are combined in a group the same way as when the "breakBefore" attribute is used for columns to add a moving to the next rows, but the first variant is clearer from a source code. Hence, the following simple examples are very same.

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5" id="sublist"> 
        <rich:column colspan="3">
            <f:facet name="header">State Flag</f:facet>
            <h:graphicImage value="#{cap.stateFlag}"/>
        </rich:column>
        <rich:columnGroup>
            <rich:column> 
                <h:outputText value="#{cap.state}"/>
            </rich:column>
            <rich:column >
                <h:outputText value="#{cap.name}"/>
            </rich:column>
            <rich:column >
                <h:outputText value="#{cap.timeZone}"/>
            </rich:column>
        </rich:columnGroup> 
    </rich:dataTable>
...

And representation without a grouping:

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5" id="sublist"> 
        <rich:column colspan="3">
            <f:facet name="header">State Flag</f:facet>
            <h:graphicImage value="#{cap.stateFlag}"/>
        </rich:column>
        <rich:column breakBefore="true">...</rich:column>
        <rich:column >...</rich:column>
        <rich:column >...</rich:column>
    </rich:dataTable>
....

The result is:

Generated columnGroup component

Figure 6.22. Generated columnGroup component


It's also possible to use the component for output of complex headers in a table. For example adding of a complex header to a facet for the whole table looks the following way:

Example:


...
    <f:facet name="header">
        <rich:columnGroup>
            <rich:column rowspan="2">
                <h:outputText value="State Flag"/>
            </rich:column>
            <rich:column colspan="3">
                <h:outputText value="State Info"/>
            </rich:column>
            <rich:column breakBefore="true">
                <h:outputText value="State Name"/>
            </rich:column>
            <rich:column>
                <h:outputText value="State Capital"/>
            </rich:column>
            <rich:column>
                <h:outputText value="Time Zone"/>
            </rich:column>
        </rich:columnGroup>
    </f:facet>
...

Generated on a page as:

ColumnGroup with complex headers

Figure 6.23. ColumnGroup with complex headers


6.34.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all columnGroups at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the columnGroup to your page style sheets

6.34.7. Definition custom style classes

To redefine an appearance of all columnGroups on a page, redefine the corresponding class in the CSS file used with the page.

To redefine a style of a particular page, use component class attributes which list is the same as the columnGroup one and is known to you.

6.34.8. Relevant resources links

Here you can see the example of <rich:columnGroup> usage and sources for the given example.

6.35.  < rich:dndParam >

6.35.1. Description

This component is used for passing parameters during drag-and-drop operations.

Table 6.97. rich : dndParam attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
nameA name of this parameter
renderedIf "false", this component is not rendered
typeThis attribute defines parameter functionality. Possible values are "drag", "drop" and "default"
valueThe current value for this component

Table 6.98. Component identification parameters

NameValue
component-typeorg.richfaces.DndParam
component-classorg.richfaces.component.html.HtmlDndParam
tag-classorg.richfaces.taglib.DndParamTag

6.35.2. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page, nested in one of the drag-and-drop components:

Example:


...
    <rich:dragSupport dragType="file">
        <rich:dndParam name="testDrag" value="testDragValue" 
                        type="drag"/>
    </rich:dragSupport>
...

6.35.3. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlDndParam;
...
HtmlDndParam myDparam = new HtmlDndParam();
...

6.35.4. Details of Usage

dndParam is used during drag-and-drop operations to pass parameters to an indicator. At first, a parameter type is defined with the type attribute (to specify parameter functionality), then a parameter name could be defined with the name and value attribute. Although, it's possible to use nested content defined inside dndParam for value definition, instead of the attribute.

Variants of usage:

  • Parameters passing for a drag icon when an indicator is in drag.

In this case, dndParam is of a drag type and is defined in the following way:

Example:


...
    <rich:dragSupport ...> 
        <rich:dndParam type="drag" name="dragging"> 
            <h:graphicImage value="/img/product1_small.png"/> 
        </rich:dndParam> 
        <h:graphicImage value="product1.png"/> 
    </rich:dragSupport>
...

Here dndParam defines an icon that is used by an indicator when a drag is on the place of a default icon (e.g. a minimized image of a draggable element)

  • Parameters passing for an indicator informational part during a drag.

In this case dndParam is of a drag type and is defined in the following way:

Example:


...
    <rich:dragSupport ...> 
        <rich:dndParam type="drag" name="label" value="#{msg.subj}"/>
        ...
    </rich:dragSupport>
...

The parameter is transmitted into an indicator for usage in an informational part of the dragIndicator component (inside an indicator a call to {label} happens)

  • Parameters passing happens when dragged content is brought onto some zone with dropSupport

In this case dndParam is of a drop type and is defined in the following way:

Example:


...
    <rich:dropSupport ...> 
        <rich:dndParam type="drop" name="comp" > 
            <h:graphicImage height="16" width="16" value="/images/comp.png"/> 
        </rich:dndParam>
        ...
    </rich:dropSupport >
...

Here, dndParam passes icons into an indicator, if dragged content of a comp type is above the given drop zone that processes it on the next drop event.

6.35.5. Relevant resources links

Here you can see the example of <rich:dndParam> usage and sources for the given example.

6.36.  < rich:dropSupport >

6.36.1. Description

This component transforms a parent component into a target zone for drag-and-drop operations. When a draggable element is moved and dropped onto the area of the parent component, Ajax request processing for this event is started.

DropSupport component

Figure 6.24. DropSupport component


6.36.2. Key Features

  • Encodes all necessary JavaScript to perform drop actions

  • Can be used within any component type that provides the required properties for drop operations

  • Built-in Ajax processing

Table 6.99. rich : dropSupport attributes

Attribute NameDescription
acceptedTypesList of drag types to be processed by the current drop zone
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disableDefaultDisable default action for target event (append "return false;" to JavaScript)
dropListenerMethodBinding representing an action listener method that will be notified after drop operation.
dropValueData to be processed after a drop event
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
ondragenterA JavaScript event handler called on enter draggable object to zone
ondragexitA JavaScript event handler called after a drag object leaves zone
ondropA JavaScript event handler called after a drag object is dropped to zone
ondropendA JavaScript handler for event fired on a drop even the drop for a given type is not available
onsubmitJavaScript code for call before submission of ajax event
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
typeMappingMap between a draggable type and an indicator name on zone. it's defined with the pair (drag type:indicator name))
valueThe current value for this component

Table 6.100. Component identification parameters

NameValue
component-typeorg.richfaces.DropSupport
component-classorg.richfaces.component.html.HtmlDropSupport
component-familyorg.richfaces.DropSupport
renderer-typeorg.richfaces.DropSupportRenderer
tag-classorg.richfaces.taglib.DropSupportTag

6.36.4. Creating the Component with a Page Tag

This simple example shows how to make a panel component a potential drop target for drag-and-drop operations using "text" elements as the dragged items.

Example:


...
    <rich:panel>
        <rich:dropSupport acceptedTypes="text"/>
    </rich:panel>
...

6.36.5. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlDropSupport;
...
HtmlDropSupport myDragZone = new HtmlDropSupport();
...

6.36.6. Details of Usage

As shown in the example, the key attribute for <rich:dropSupport> is "acceptedTypes" . This attribute defines the types of draggable items that can be dropped onto the designated drop zone.

The second most important attribute for <rich:dropSupport> is "typeMapping" . This attribute maps a specific type among the acceptable types for draggable items to a specific <rich:dndParam> child element under <rich:dropSupport> .

Example:


...
    <rich:dropSupport acceptedTypes="[iconsDragged, textDragged]" typeMapping="{iconsDragged: DropIcon}"> 
        <rich:dndParam name="DropIcon">
            <h:graphicImage value="/images/drop-icon.png"/>
        </rich:dndParam>
...

In this example, dropping a draggable item of an "iconsDragged" type will trigger the use a parameter named "DropIcon" in the event processing after a drop event. (Also, an Ajax request is sent, and the action and dropListener defined for the component are called.)

Here is an example of moving records between tables. The example describes all the pieces for drag-and-drop. (To get extra information on these components, read the sections for these components.)

As draggable items, this table contains a list of such items designated as being of type "text":

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="caps">
        <f:facet name="caption">Capitals List</f:facet>
        <h:column>
        <a4j:outputPanel>
            <rich:dragSupport dragIndicator=":form:ind" dragType="text">
                <a4j:actionparam value="#{caps.name}" name="name"/>
            </rich:dragSupport>
            <h:outputText value="#{caps.name}"/> 
        </a4j:outputPanel>
        </h:column>
    </rich:dataTable>
...

As a drop zone, this panel will accept draggable items of type "text" and then rerender an element with the ID of "box":

Example:


...
    <rich:panel style="width:100px;height:100px;">
        <f:facet name="header">Drop Zone</f:facet>
        <rich:dropSupport acceptedTypes="text" reRender="box" 
                        dropListener="#{capitalsBean.addCapital2}"/>
    </rich:panel>
...

As a part of the page that can be updated in a partial page update, this table has an ID of "box":

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals2}" var="cap2" id="box">
        <f:facet name="caption">Capitals chosen</f:facet>
        <h:column>
            <h:outputText value="#{cap2.name}"/>
        </h:column>
    </rich:dataTable>
...

And finally, as a listener, this listener will implement the dropped element:

Example:


...
    public void addCapital2(DropEvent event) {
        FacesContext context = FacesContext.getCurrentInstance();
        Capital cap = new Capital();
        cap.setName(context.getExternalContext().getRequestParameterMap().get("name").toString());
        capitals2.add(cap);
    }
...

Here is the result after a few drops of items from the first table:

Results of drop actions

Figure 6.25. Results of drop actions


In this example, items are dragged element-by-element from the rendered list in the first table and dropped on a panel in the middle. After each drop, a drop event is generated and a common Ajax request is performed that renders results in the third table.

As with every Ajax action component, <rich:dropSupport> has all the common attributes ( "timeout", "limitToList", "reRender", etc.) for Ajax request customization.

Finally, the component has the following extra attributes for event processing on the client:

  • ondragenter
  • ondragexit
  • ondrop
  • ondropend

Developers can use their own custom JavaScript functions to handle these events.

6.36.7. Look-and-Feel Customization

The component doesn't have its own visual presentation.

6.36.8. Relevant resources links

Here you can see the example of <rich:dropSupport> usage and sources for the given example.

6.37.  < rich:dragIndicator >

6.37.1. Description

This is a component for defining what appears under the mouse cursor during drag-and-drop operations. The displayed drag indicator can show information about the dragged elements.

DragIndicator component

Figure 6.26. DragIndicator component


Table 6.101. rich : dragIndicator attributes

Attribute NameDescription
acceptClassCorresponds to the HTML class attribute and added to an indicator when a drop is accepted
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
rejectClassCorresponds to the HTML class attribute and added to an indicator when a drop is rejected
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute

Table 6.102. Component identification parameters

NameValue
component-typeorg.richfaces.Draggable
component-classorg.richfaces.component.html.HtmlDragIndicator
component-familyorg.richfaces.DragIndicator
renderer-typeorg.richfaces.DragIndicatorRenderer
tag-classorg.richfaces.taglib.DragIndicatorTag

6.37.2. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


... 
    <dnd:dragIndicator  id="indicator">
        <f:facet name="single">
            <f:verbatim>
                <b>Single item</b> {DragInfo}
            </f:verbatim>
        </f:facet>
    </dnd:dragIndicator>
    ...
    <dnd:dragSupport dragType="text" dragIndicator="indicator">
...

6.37.3. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlDragIndicator;
...
HtmlDragIndicator myDragIndicator = new HtmlDragIndicator();
...

6.37.4. Details of Usage

In the simplest way the component could be defined empty - in that case a default indicator will be shown like this:

Simplest dragIndicator

Figure 6.27. Simplest dragIndicator


For indicator customization you need to define one of the following facets:

  • single

Indicator shown when dragging a single element.

  • multy

Indicator shown when dragging several components (for future components that will support multiple selection).

Thus for specify a look-and-feel you have to define one of these facets and include into it a content that should be shown in indicator.

6.37.4.1. Macro defenitions

To place some data from drag or drop zones into component you can use macro defenitions. They are being defining in the following way:

  • <rich:dndParam> component with a specific name and value is being included into a drag/drop support component (an image can be defined as placed inside <rich:dndParam> without defining a value).
  • in needed place a parameter value is included into the marking of indicator using syntax (name of parameter)

For instance, this:


... 
    <dnd:dropSupport...>
        <dnd:dndParam name="testDrop">
            <h:graphicImage value="/images/file-manager.png" />
        </dnd:dndParam>
    </dnd:dropSupport>
...

..Is placed into indicator as follows:


... 
    <f:facet name="single">
        {testDrop}
    </f:facet>
...

6.37.4.2. Predefined macro defenitions

Indicator can accept two default macro defenitions:

  • marker
  • label

Thus including one of these elements in the marking of indicator, in other words after setting up appropriate parameters in DnD components and defining only default indicator - without specifying facets - a developer gets these parameters values displayed in indicator in the order "marker - label".

6.37.4.3. Marker customization

The macro defenition "marker" can be customized depending on what a draggable element is located over. For that you should define one of these three parameters (specify a parameter with one of three names):

  • accept

Parameter will be set instead of {marker} into indicator when a draggable element is positioned over drop zone that accept this type of elements

  • reject

Parameter will be set instead of {marker} into indicator when a draggable element is positioned over drop zone that doesn't accept this type of elements

  • default

Parameter will be set instead of {marker} into indicator when a draggable element is positioned over all the rest of page elements

6.37.5. Relevant resources links

Here you can see the example of <rich:dragIndicator> usage and sources for the given example.

6.38.  < rich:dragSupport >

6.38.1. Description

This component defines a subtree of the component tree as draggable for drag-and-drop operations. Within such a "drag zone," you can click the mouse button on an item and drag it to any component that supports drop operations (a "drop zone"). It encodes all the necessary JavaScript for supporting drag-and-drop operations.

DragSupport component

Figure 6.28. DragSupport component


6.38.2. Key Features

  • Encodes all necessary JavaScript to perform drag actions
  • Can be used within any component type that provides the required properties for drag operations

Table 6.103. rich : dragSupport attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disableDefaultDisable default action for target event (append "return false;" to JavaScript)
dragIndicatorId of the dragIndicator component used as drag operation cursor
dragListenerMethodBinding representing an action listener method that will be notified after drag operation
dragTypeKey of a drag object. It's used to define a necessity of processing the current dragged element on the drop zone side
dragValueData to be sent to the drop zone after a drop event
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
ondragendA JavaScript event handler called after a drag operation
ondragstartA JavaScript event handler called before drag object
onsubmitJavaScript code for call before submission of ajax event
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component

Table 6.104. Component identification parameters

NameValue
component-typeorg.richfaces.DragSupport
component-classorg.richfaces.component.html.HtmlDragSupport
component-familyorg.richfaces.DragSupport
renderer-typeorg.richfaces.DragSupportRenderer
tag-classorg.richfaces.taglib.DragSupportTag

6.38.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <h:panelGrid id="drag1">
        <rich:dragSupport dragType="item"/>
            <!--Some content to be dragged-->
    </h:panelGrid>
...

6.38.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlDragSupport;
...
HtmlDragSupport myDragZone = new HtmlDragSupport();
...

6.38.5. Details of Usage

The dragSupport tag inside a component completely specifies the events and JavaScript required to use the component and it's children for dragging as part of a drag-and-drop operation. In order to work, though, dragSupport must be placed inside a wrapper component that outputs child components and that has the right events defined on it. Thus, this example won't work, because the h:column tag doesn't provide the necessary properties for redefining events on the client:

Example:


...
    <h:column>
        <rich:dragSupport dragIndicator=":form:iii" dragType="text">
            <a4j:actionparam value="#{caps.name}" name="name"/>
        </rich:dragSupport>
        <h:outputText value="#{caps.name}"/> 
    </h:column>
...

However, using a4j:outputPanel as a wrapper inside h:column, the following code could be used successfully:

Example:


...
    <h:column>
        <a4j:outputPanel>
            <rich:dragSupport dragIndicator=":form:iii" dragType="text">
                <a4j:actionparam value="#{caps.name}" name="name"/>
            </rich:dragSupport>
            <h:outputText value="#{caps.name}"/> 
        </a4j:outputPanel>
    </h:column>
...

This code makes all rows of this column draggable.

One of the main attributes for dragSupport is "dragType", which associates a name with the drag zone. Only drop zones with this name as an acceptable type can be used in drag-and-drop operations. Here is an example:

Example:


...
    <h:panelGrid id="drag1">
        <rich:dragSupport dragType="singleItems" .../>
        <!--Some content to be dragged-->
    </h:panelGrid>      
...
    <h:panelGrid id="drag2">
        <rich:dragSupport dragType="groups" .../>
        <!--Some content to be dragged-->
    </h:panelGrid>      
...
    <h:panelGrid id="drop1">
        <rich:dropSupport acceptedTypes="singleItems" .../>
        <!--Drop zone content-->
    </h:panelGrid>
...

In this example, the drop1 panel grid is a drop zone that invokes drag-and-drop for drops of items from the first drag1 panel grid, but not the second drag2 panel grid. In the section about dropSupport, you will find an example that shows more detailed information about moving data between tables with drag and drop.

The dragSupport component also has a "value" attribute for passing data into the processing after a drop event.

One more important attribute for <rich:dragSupport> is the "dragIndicator" attribute that point to the component id of the <rich:dragIndicator> component to be used for dragged items from this drag zone. If it isn't defined, a default indicator for drag operations is used.

Finally, the component has the following extra attributes for event processing on the client:

  • ondragenter
  • ondragexit

You can use your own custom JavaScript functions to handle these events.

6.38.6. Look-and-Feel Customization

The component doesn't have its own representation.

6.38.7. Relevant resources links

Here you can see the example of <rich:dragSupport> usage and sources for the given example.

6.39.  < rich:dropListener >

6.39.1. Description

The <rich:dropListener> represents an action listener method that will be notified after drop operation.

6.39.2. Key Features

  • Allows to define some drop listeners for the components with "Drag and Drop" support

Table 6.105. rich : dropListener attributes

Attribute NameDescription
binding The attribute takes a value-binding expression for a component property of a backing bean
type Attribute defines the fully qualified Java class name for listener

Table 6.106. Component identification parameters

NameValue
listener-classorg.richfaces.event.DropListener
event-classorg.richfaces.event.DropEvent
tag-classorg.richfaces.taglib.DropListenerTag

6.39.3. Creating on a page

Simple Component definition on a page:

Example:


...
    <rich:dropListener type="demo.Bean"/>
...

6.39.4. Dynamical creation of a component from Java code

Example:


package demo;
      
public class ImplBean implements org.richfaces.event.DropListener{
    ...
}


import demo.ImplBean;
...
ImplBean myListener = new ImplBean();
...

6.39.5. Key attributes and ways of usage

The <rich:dropListener> is used as nested tag with components like <rich:dropSupport>, <rich:tree> and <rich:treeNode>.

Attribute "type" defines the fully qualified Java class name for listener. This class should implement org.richfaces.event.DropListener interface.

The typical variant of using:


...
<rich:panel style="width:100px;height:100px;">
    <f:facet name="header">Drop Zone</f:facet>
    <rich:dropSupport acceptedTypes="text"> 
        <rich:dropListener type="demo.ListenerBean"/>
    </rich:dropSupport>             
</rich:panel>
...

Java bean source:


package demo;

import org.richfaces.event.DropEvent;

public class ListenerBean implements org.richfaces.event.DropListener{
... 
    public void processDrop(DropEvent arg0){
        //Custom Developer Code 
    }
...
}

6.40.  < rich:dragListener >

6.40.1. Description

The <rich:dragListener> represents an action listener method that will be notified after drag operation.

6.40.2. Key Features

  • Allows to define some drag listeners for the components with "Drag and Drop" support

Table 6.107. rich : dragListener attributes

Attribute NameDescription
binding The attribute takes a value-binding expression for a component property of a backing bean
type Attribute defines the fully qualified Java class name for listener

Table 6.108. Component identification parameters

NameValue
listener-classorg.richfaces.event.DragListener
event-classorg.richfaces.event.DragEvent
tag-classorg.richfaces.taglib.DragListenerTag

6.40.3. Creating on a page

Simple Component definition on a page:

Example:


...
    <rich:dragListener type="demo.Bean"/>
...

6.40.4. Dynamical creation of a component from Java code

Example:


package demo;
      
public class ImplBean implements org.richfaces.event.DragListener{
    ...
}


import demo.ImplBean;
...
ImplBean myDragListener = new ImplBean();
...

6.40.5. Key attributes and ways of usage

The <rich:dragListener> is used as nested tag with components like <rich:dragSupport>, <rich:tree> and <rich:treeNode>.

Attribute "type" defines the fully qualified Java class name for listener. This class should implement org.richfaces.event.DragListener interface.

The typical variant of using:


...
<h:panelGrid id="dragPanel">
    <rich:dragSupport dragType="item">
        <rich:dragListener type="demo.ListenerBean"/>   
    </rich:dragSupport>
    <!--Some content to be dragged-->
</h:panelGrid>
...

Java bean source:


package demo;

import org.richfaces.event.DragEvent;

public class ListenerBean implements org.richfaces.event.DragListener{
... 
    public void processDrag(DragEvent arg0){
        //Custom Developer Code 
    }
...
}

6.41.  < rich:dropDownMenu >

6.41.1. Description

The <rich:dropDownMenu> component is used for creating multilevel drop-down menus.

<rich:dropDownMenu> component

Figure 6.29. <rich:dropDownMenu> component


6.41.2. Key Features

  • Highly customizable look-and-feel

  • Pop-up appearance event customization

  • Different submission modes

  • Ability to define a complex representation for elements

  • Support for disabling

  • Smart user-defined positioning

Table 6.109. rich : dropDownMenu attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
directionDefines direction of the popup list to appear (top-right, top-left bottom-right, bottom-left, auto(default))
disabledItemClassSpace-separated list of CSS style class(es) that are be applied to disabled item of this component
disabledItemStyleCSS style(s) is/are to be applied to disabled item when this component is rendered.
eventDefines the event on the representation element that triggers the menu's appearance.
hideDelayDelay between losing focus and menu closing.
horizontalOffsetSets the horizontal offset between popup list and label element conjunction point
idEvery component may have a unique id that is automatically created if omitted
itemClassSpace-separated list of CSS style class(es) that are be applied to item of this component
itemStyleCSS style(s) is/are to be applied to item when this component is rendered.
jointPointSet the corner of the label for the popup to be connected with. (auto(default), tr, tl, bl, br, where tr – top-right)
oncollapseEvent must occurs on menu closure
onexpandEvent must occurs on menu opening
ongroupactivateHTML: script expression; some group was activated.
onitemselectHTML: script expression; some item was selected.
onmousemoveHTML: script expression; a pointer was moved within.
onmouseoutHTML: script expression; a pointer was moved away.
onmouseoverHTML: script expression; a pointer was moved onto.
popupWidthSet minimal width for the all of the lists that will appear.
renderedIf "false", this component is not rendered
selectItemClassSpace-separated list of CSS style class(es) that are be applied to selected item of this component.
selectItemStyleCSS style(s) is/are to be applied to selected item when this component is rendered.
showDelayDelay between event and menu showing.
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
submitModeSet the submission mode for all menu items of the menu except ones where this attribute redefined. (ajax,server(Default),none)
valueDefines representation text for Label used for menu calls.
verticalOffsetSets the vertical offset between popup list and label element conjunction point

Table 6.110. Component identification parameters

NameValue
component-typeorg.richfaces.DropDownMenu
component-classorg.richfaces.component.html.HtmlDropDownMenu
component-familyorg.richfaces.DropDownMenu
renderer-typeorg.richfaces.DropDownMenuRenderer
tag-classorg.richfaces.taglib.DropDownMenuTag

6.41.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:dropDownMenu value="Item1">
        <!--Nested menu components-->
    </rich:dropDownMenu>
...
  

6.41.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlDropDownMenu;   
...
HtmlDropDownMenu myDropDownMenu = new HtmlDropDownMenu();
...

6.41.5. Details of Usage

All attributes except "value" are optional. The "value" attribute defines text to be represented. If you can use the "label" facet, you can even not use the "value" attribute.

Here is an example:

Example:


...
    <f:facet name="label">
        <h:graphicImage value="/images/img1.gif"/>
    </f:facet>
...
  

Use the "event" attribute to define an event for the represented element that triggers a menu appearance. An example of a menu appearance on a click can be seen below.

Example:


...
    <rich:dropDownMenu event="onclick" value="Item1">
        <!--Nested menu components-->
    </rich:dropDownMenu>
...

The <rich:dropDownMenu> "submitMode" attribute can be set to three possible parameters:

  • Server (default)

The standard form submission is performed and the page is completely refreshed.

  • Ajax

An Ajax form submission is performed, and specified elements in the "reRender" attribute are rerendered.

  • None

The "action" and "actionListener" item's attributes are ignored. Menu items don't fire any submits themselves. The behavior is fully defined by the components nested inside items.

Note:

As the <rich:dropDownMenu> component doesn't provide its own form, use it between <h:form> and </h:form> tags.

The "direction" and "jointPoint" attributes are used for defining aspects of menu appearance.

Possible values for the "direction" attribute are:

  • top-left - a menu drops to the top and left

  • top-right - a menu drops to the top and right

  • bottom-left - a menu drops to the bottom and left

  • bottom-right - a menu drops to the bottom and right

  • auto - smart positioning activation

Possible values for the "jointPoint" attribute are:

  • tr - a menu is attached to the top-right point of the button element

  • tl - a menu is attached to the top-left point of the button element

  • br - a menu is attached to the bottom-right point of the button element

  • bl - a menu is attached to the bottom-left point of the button element

  • auto - smart positioning activation

By default, the "direction" and "jointPoint" attributes are set to "auto" .

Here is an example:

Example:


...
    <rich:dropDownMenu value="Item1" direction="bottom-right" jointPoint="tr">
        <!--Nested menu components-->
    </rich:dropDownMenu>
...

This is the result:

Using the "direction" and"joinPoint" attributes

Figure 6.30. Using the "direction" and"joinPoint" attributes


You can correct an offset of the pop-up list relative to the label using the following attributes: "horizontalOffset" and "verticalOffset" .

Here is an example:

Example:


...
    <rich:dropDownMenu value="Item1" direction="bottom-right" jointPoint="tr" horizontalOffset="-15" verticalOffset="0">
        <!--Nested menu components-->
    </rich:dropDownMenu>
...
  

This is the result:

Using the "horizontalOffset" and "verticalOffset" attributes

Figure 6.31. Using the "horizontalOffset" and "verticalOffset" attributes


6.41.6. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all drop-down menus at once:

  • Redefine the corresponding skin parameters

  • Add to your style sheets style classes used by a drop-down menu

6.41.7.  Skin parameters redefinition

Table 6.111. Skin parameters redefinition for a label <div> element

Skin parametersCSS properties
generalFamilyFontfont-family
generalSizeFontfont-size

Table 6.112. Skin parameters redefinition for a selected label

Skin parametersCSS properties
panelBorderColorborder-color
controlBackgroundColorbackground-color
generalTextColorbackground-colorcolor

Table 6.113. Skin parameters redefinition for a border

Skin parametersCSS properties
panelBorderColorborder-color
additionalBackgroundColorbackground-color

Table 6.114. Skin parameters redefinition for a background

Skin parametersCSS properties
additionalBackgroundColorborder-top-color
additionalBackgroundColorborder-left-color
additionalBackgroundColorborder-right-color

6.41.8. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Classes names

Figure 6.32. Classes names


Table 6.115. Classes names that define a label

Class nameDescription
rich-label-text-decorDefines text style for a representation element
rich-ddmenu-labelDefines styles for a wrapper <div> element of a representation element
rich-ddmenu-label-selectDefines styles for a wrapper <div> element of a selected representation element
rich-ddmenu-label-unselectDefines styles for a wrapper <div> element of an unselected representation element

On the screenshot there are classes names that define styles for component elements.

Classes names

Figure 6.33. Classes names


Table 6.116. Classes names that define a popup element

Class nameDescription
rich-menu-list-borderDefines styles for borders
rich-menu-list-bgDefines styles for a general background list

In order to redefine the style for all drop-down menus on a page using CSS, it's enough to create classes with the same names and define the necessary properties in them.

To change the style peculiarities of the particular drop-down menus define your own style classes in the corresponding dropDownMenu attributes.

6.41.9. Relevant resources links

Here you can see the example of <rich:dropDownMenu> usage and sources for the given example.

6.42.  < rich:menuGroup >

6.42.1. Description

The <rich:menuGroup> component is used to define an expandable group of items inside a pop-up list or another group.

<rich:menuGroup> component

Figure 6.34. <rich:menuGroup> component


6.42.2. Key Features

  • Highly customizable look-and-feel

  • Grouping of any menu's items

  • Pop-up appearance event customization

  • Support for disabling

  • Smart user-defined positioning

Table 6.117. rich : menuGroup attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
converterId of Converter to be used or reference to a Converter
directionDefines direction of the popup sublist to appear (right, left, auto(Default), left-down, left-up, right-down, right-up)
disabledIf "true" sets state of the item to disabled state. "false" is default
eventDefines the event on the representation element that triggers the menu's appearance
iconPath to the icon to be displayed for the enabled item state
iconClassClass to be applied to icon element
iconDisabledPath to the icon to be displayed for the disabled item state
iconFolderPath to the folder icon to be displayed for the enabled item state
iconFolderDisabledPath to the folder icon to be displayed for the enabled item state
iconStyleCSS style rules to be applied to icon element
idEvery component may have a unique id that is automatically created if omitted
oncloseHTML: script expression; group was closed
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onopenHTML: script expression; group was opened
renderedIf "false", this component is not rendered
selectClassClass to be applied to selected items
selectStyleCSS style rules to be applied to selected items
showDelayDelay between event and menu showing
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
valueDefines representation text for menuItem

Table 6.118. Component identification parameters

NameValue
component-typeorg.richfaces.MenuGroup
component-classorg.richfaces.component.html.HtmlMenuGroup
component-familyorg.richfaces.DropDownMenu
renderer-typeorg.richfaces.MenuGroupRenderer
tag-classorg.richfaces.taglib.MenuGroupTag

6.42.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:dropDownMenu value="Active">
        ...
        <rich:menuGroup value="Active">
            <!--Nested menu components-->
        </rich:menuGroup>
        ...
    </rich:dropDownMenu >
...

6.42.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlMenuGroup;  
...
HtmlMenuGroup myMenuGroup = new HtmlMenuGroup();
...

6.42.5. Details of Usage

The "value" attribute defines the text representation of a group element in the page.

The "icon" attribute defines an icon for the component. The "iconDisabled" attribute defines an icon for when the group is disabled. Also you can use the "icon" and "iconDisabled" facets. If the facets are defined, the corresponding "icon" and "iconDisabled" attributes are ignored and the facets' contents are used as icons. This could be used for an item check box implementation.

Here is an example:


...
    <f:facet name="icon">
        <h:selectBooleanCheckbox value="#{bean.property}"/>
    </f:facet>
...

The "iconFolder" and "iconFolderDisabled" attributes are defined for using icons as folder icons. The "iconFolder" and "iconFolderDisabled" facets use their contents as folder icon representations in place of the attribute values.

The "direction" attribute is used to define which way to display the menu as shown in the example below:

Possible values are:

  • left - down - a submenu is attached to the left side of the menu and is dropping down

  • left - up - a submenu is attached to the left side of the menu and is dropping up

  • right - down - a submenu is attached to the right side of the menu and is dropping down

  • right - up - a submenu is attached to the right side of the menu and is dropping up

  • auto - smart positioning activation

By default, the "direction" attribute is set to "auto" .

Here is an example:


...
    <rich:menuGroup value="Active" direction="left-down"
        <!--Nested menu components-->
    </rich:menuGroup>
...

This would be the result:

Using the "direction" attribute

Figure 6.35. Using the "direction" attribute


6.42.6. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all menu groups at once:

  • Redefine corresponding skin parameters

  • Add to your styles heet style classes used by a menu group

6.42.7. Skin parameters redefinition

Table 6.119. Skin parameters redefinition for a group

Skin parametersCSS properties
generalFamilyFontfont-family
generalSizeFontfont-size

Table 6.120. Skin parameters redefinition for a disabled group

Skin parametersCSS properties
tabDisabledTextColorcolor

Table 6.121. Skin parameters redefinition for a label

Skin parametersCSS properties
generalTextColorcolor

6.42.8. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Classes names

Figure 6.36. Classes names


Table 6.122. Classes names that define an appearance of group elements

Class nameDescription
rich-menu-groupDefines styles for a wrapper <div> element for a group
rich-menu-item-labelDefines styles for a label of an item
rich-menu-item-iconDefines styles for the left icon of an item
rich-menu-item-folderDefines styles for the right icon of an item

Table 6.123. Classes names that define different states

Class nameDescription
rich-menu-item-label-disabledDefines styles for a label of a disabled item
rich-menu-item-icon-disabledDefines styles for the left icon of a disabled item
rich-menu-item-folder-disabledDefines styles for the right icon of a disabled item
rich-menu-group-hoverDefines styles for a wrapper <div> element of a hover group
rich-menu-item-icon-enabledDefines styles for the left icon of an enabled item
rich-menu-item-icon-selectedDefines styles for the left icon of a selected item

In order to redefine the style for all menu groups on a page using CSS, it's enough to create classes with the same names and define the necessary properties in them.

To change style aspects of particular panel menu groups define your own style classes in the corresponding menuGroup attributes.

6.42.9. Relevant resources links

Here you can see the example of <rich:menuGroup> usage and sources for the given example.

6.43.  < rich:menuItem >

6.43.1. Description

The <rich:menuItem> component is used for the definition of a single item inside a pop-up list.

<rich:menuItem> component

Figure 6.37. <rich:menuItem> component


6.43.2. Key Features

  • Highly customizable look-and-feel

  • Different submission modes

  • Support for disabling

  • Custom content support

Table 6.124. rich : menuItem attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disabledIf "true" sets state of the item to disabled state. "false" is default
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
iconPath to the icon to be displayed for the enabled item state
iconClassClass to be applied to icon element
iconDisabledPath to the icon to be displayed for the disabled item state.
iconStyleCSS style rules to be applied to icon element
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; The onselect event occurs when a user selects some menu item
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
selectClassClass to be applied to selected items
selectStyleCSS style rules to be applied to selected items
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
submitModeSet the submission mode (ajax, server(Default), none)
targetName of a frame where the resource retrieved via this hyperlink is to be displayed
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component

Table 6.125. Component identification parameters

NameValue
component-typeorg.richfaces.MenuItem
component-classorg.richfaces.component.html.HtmlMenuItem
component-familyorg.richfaces.DropDownMenu
renderer-typeorg.richfaces.MenuItemRenderer
tag-classorg.richfaces.taglib.MenuItemTag

6.43.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:dropDownMenu>
        ...
        <rich:menuItem value="Active"/>
        ...
    <rich:dropDownMenu>
...

6.43.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlMenuItem;   
...
HtmlMenuItem myMenuItem = new HtmlMenuItem();
...

6.43.5. Details of Usage

The "value" attribute defines the text representation for an item element.

There are two icon-related attributes. The "icon" attribute defines an icon. The "iconDisabled" attribute defines an icon for a disabled item. Also you can use the "icon" and "iconDisabled" facets. If the facets are defined, the corresponding "icon" and "iconDisabled" attributes are ignored and the facets content is shown as an icon. It could be used for an item check box implementation.

Here is an example:


...
    <f:facet name="icon">
        <h:selectBooleanCheckbox value="#{bean.property}"/>
    </f:facet>
...

The <rich:menuItem> "submitMode" attribute can be set to three possible parameters:

  • Server (default)

The standard form submission is performed and the page is completely refreshed.

  • Ajax

An Ajax form submission is performed, and specified elements in the "reRender" attribute are rerendered.

  • None

The "action" and "actionListener" item's attributes are ignored. Menu items don't fire any submits themselves. The behavior is fully defined by the components nested inside items.

For example, you can put any content into an item, but, in this case, you should set the "mode" attribute as "none" .

Here is an example:


...
    <rich:dropDownMenu>
        ...
        <rich:menuItem submitMode="none">
            <h:outputLink value="www.jboss.org"/>
        </rich:menuItem>
        ...
    <rich:dropDownMenu>
...

You can use the "disabled" attribute to set the item state.

Here is an example:


...
    <rich:dropDownMenu>
        <rich:menuItem value="Disable" disabled="true"/>
    <rich:dropDownMenu>
...

6.43.6.  Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all menu items at once:

  • Redefine the corresponding skin parameters

  • Add to your style sheets style classes used by a menu item

6.43.7. Skin parameters redefinition

Table 6.126. Skin parameters redefinition for an item

Skin parametersCSS properties
generalFamilyFontfont-family
generalSizeFontfont-size

Table 6.127. Skin parameters redefinition for a hovered item

Skin parametersCSS properties
tipBorderColorborder-color
tipBackgroundColorbackground-color

Table 6.128. Skin parameters redefinition for a disabled item

Skin parametersCSS properties
tabDisabledTextColorcolor

Table 6.129. Skin parameters redefinition for a label

Skin parametersCSS properties
generalTextColorcolor

6.43.8.  Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Class names

Figure 6.38. Class names


Table 6.130. Classes names that define an appearance of item elements

Class nameDescription
rich-menu-itemDefines styles for a wrapper <div> element for an item
rich-menu-item-labelDefines styles for a label of an item
rich-menu-item-iconDefines styles for the left icon of an item

Table 6.131. Classes names that define different states

Class nameDescription
rich-menu-item-disabledDefines styles for a wrapper <div> element of an item
rich-menu-item-enabledDefines styles for a wrapper <div> element of an enabled item
rich-menu-item-hoverDefines styles for a wrapper <div> element of a hover item
rich-menu-item-label-disabledDefines styles for a label of a disabled item
rich-menu-item-icon-disabledDefines styles for the left icon of a disabled item
rich-menu-item-label-enabledDefines styles for a label of an enabled item
rich-menu-item-icon-enabledDefines styles for the left icon of an enabled item
rich-menu-item-label-selectedDefines styles for a label of a selected item
rich-menu-item-icon-selectedDefines styles for the left icon of a selected item

In order to redefine the style for all menu items on a page using CSS, it's enough to create classes with the same names and define the necessary properties in them.

To change the style of particular menu items define your own style classes in the corresponding menuItem attributes.

6.43.9. Relevant resources links

Here you can see the example of <rich:menuItem> usage and sources for the given example.

6.44.  < rich:menuSeparator >

6.44.1. Description

The <rich:menuSeparator> component is used for the definition of a horizontal separator that can be placed between groups or items.

<rich:menuSeparator>

Figure 6.39. <rich:menuSeparator>


Table 6.132. rich : menuSeparator attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
renderedIf "false", this component is not rendered

Table 6.133. Component identification parameters

NameValue
component-typeorg.richfaces.MenuSeparator
component-classorg.richfaces.component.html.HtmlMenuSeparator
component-familyorg.richfaces.DropDownMenu
renderer-typeorg.richfaces.MenuSeparatorRenderer
tag-classorg.richfaces.taglib.MenuSeparatorTag

6.44.2. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:dropDownMenu/>
        ...
        <rich:menuSeparator/>
        ...
    <rich:dropDownMenu/>
...

6.44.3. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlMenuSeparator;  
...
HtmlMenuSeparator myMenuSeparator = new HtmlMenuSeparator();
...

6.44.4. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all menu separators at once:

  • Redefine the corresponding skin parameters

  • Add to your style sheets style classes used by a menu separator

6.44.5. Redefinition of Skin Parameters

Table 6.134. Label skin parameters redefinition

Skin parameters for itemCSS properties
panelBorderColorborder-top-color

6.44.6. Definition of Custom Style Classes

In the screenshot, there are the classes names that define separator element appearance.

Classes names

Figure 6.40. Classes names


Table 6.135. Classes names that define separator element appearance.

Class nameDescription
Rich-menu-itemDefines the class for div element for separator

In order to redefine a style for all menu separators in a page using CSS, it's enough to create classes with the same names and define the necessary properties in them.

To change the style peculiarities of the particular menu separators, define your own style classes in the corresponding menuSeparator attributes.

6.44.7. Relevant resources links

Here you can see the example of <rich:menuSeparator> usage and sources for the given example.

6.45.  < rich:effect >

6.45.1. Description

The rich:effect utilizes a set of effects provided by the scriptaculous JavaScript library. It allows to attach effects to JSF components and html tags.

6.45.2. Key Features

  • No developers JavaScript writing needed to use it on pages
  • Presents scriptaculous JavaScript library functionality

Table 6.136. rich : effect attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
disableDefaultDisable default action for target event ( append "return false;" to javascript )
eventEvent on the component or html tag the effect is attached to
forId of the target component.
idEvery component may have a unique id that is automatically created if omitted
nameGenerated Javascript name.
paramsParameters passed to the effect function. Example params="{duration:0.2,from:1.0,to:0.1}"
renderedIf "false", this component is not rendered
targetIdThe id of the element the effect apply to. Might be component id or client id of jsf component or html tag. If targetId is not defined the value of the attribute 'for' or the 'targetId' option effect play its role
typeDefines the type of effect. Possible values: "Fade", "Blind", "Opacity".

Table 6.137. Component identification parameters

NameValue
component-typeorg.richfaces.Effect
component-classorg.richfaces.component.html.HtmlEffect
component-familyorg.richfaces.Effect
renderer-typeorg.richfaces.EffectRenderer
tag-classorg.richfaces.taglib.EffectTag

6.45.3. Creating the Component with a Page Tag

To create the simplest variant of rich:effect on a page, use the following syntax:

Example:


...
<rich:effect for="componentId" type="Appear"/>
...

6.45.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlRichEffect;
...
HtmlRichEffect myEffect = new HtmlRichEffect();
...

6.45.5. Details of Usage

It is possible to use <rich:effect> in two modes:

  • attached to the JSF components or html tags and triggered by a particular event. Wiring effect with JSF components might occur on the server or client. Wiring with html tag is possible only on the client side
  • invoking from the JavaScript code by an effect name. During the rendering, rich:effect generates the JavaScript function with defined name. When the function is called, the effect is applied

Those a the typical variants of using:


...
<!-- attaching by event  -->
<rich:panel>
    <rich:effect event="onmouseout" type="Opacity" params="duration:0.8,from:1.0,to:0.3" />
    .... panel content ....
</rich:panel>
...

<!--  invoking from JavaScript -->
<div id="contentDiv">
  ..... div content ......
</div>

<input type="button" onclick="hideDiv({duration:0.7})" value="Hide" />
<input type="button" onclick="showDiv()" value="Show" />

<rich:effect  name="hideDiv"  for="contentDiv" type="Fade" />
<rich:effect  name="showDiv"  for="contentDiv" type="Appear" />

<!-- attaching to window on load and applying on particular page element -->
<rich:effect for="window" event="onload" type="Appear" params="id:'contentDiv',duration:0.8,from:0.3,to:1.0" />
...
Initial:

Figure 6.41. Initial:


When the mouse cursor is over:

Figure 6.42. When the mouse cursor is over:


"name" attribute defines a name of the JavaScript function that is be generated on a page when the component is rendered. You can invoke this function to activate the effect. The function accesses one parameter. It is a set of effect options in JSON format.

"type" attribute defines the type of an effect. For example, "Fade", "Blind", "Opacity". Have a look at scriptaculous documentation for set of available effect.

"for" attribute defines the id of the component or html tag, the effect will be attached to. Richfaces converts the "for" attribute value to the client id of the component if such component is found. If not, the value is left as is for possible wiring with on the DOM element's id on the client side. By default, the target of the effect is the same element that effect pointed to. However, the target element is might be overridden with "effectId" option passed with "params" attribute of with function paramenter.

"params" attribute allows to define the set of options possible for particurar effect. For example, 'duration', 'delay', 'from', 'to'. Additionally to the options used by the effect itself, there are two option that might override the rich:effect attribute. Those are:

  • "effectId" allows to re-define the target of effect. The option is override the value of "for" attribute
  • "effectType" defines the effect type. The option is override the value of "type" attribute

6.45.6. Relevant resources links

Here you can see the example of <rich:effect> usage.

How to save <rich:effect> status see on the RichFaces Users Forum.

6.46.  < rich:gmap >

6.46.1. Description

Component that presents the Google map in the JSF applications.

Gmap component

Figure 6.43. Gmap component


6.46.2. Key Features

  • Presents all the Google map functionality
  • Highly customizable via attributes
  • No developers JavaScript writing needed to use on a pages

Table 6.138. rich : gmap attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
enableContinuousZoomEnables continuous smooth zooming for selected browsers. The default value is "false"
enableDoubleClickZoomEnables zooming in by a double click. The default value is "false"
enableDraggingEnables a map dragging with the mouse. The default value is "true"
enableInfoWindowEnables Info Window. The default value is "true"
gmapKeyGoogle Map key. A single Maps API key is valid for a single "directory" on your web server
gmapVarThe JavaScript variable that is used to access the Google Map API. If you have more than one Google Map components on the same page, use individual key for each of them. The default variable name is "map" (without quotes)
idEvery component may have a unique id that is automatically created if omitted
latInitial latitude coordinate in degrees, as a number between -90 and +90
lngInitial longitude coordinate in degrees, as a number between -180 and +180
mapTypeInitial map type. The possible values are G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP. The default value is G_SATELLITE_MAP
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
oninitJavaScript code invoked just after the Google Map object is initiated.
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
showGLargeMapControlShows the GLarge control. The default value is "true"
showGMapTypeControlShows the Type switch control. The default value is "true"
showGScaleControlIt shows the scale control. The default value is "true"
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
warningMessageThe warning message that appears if a browser is not compatible with Google Map. The default value is "Your browser does not support Google Maps"
zoomInitial zoom level as a number between 1 and 18. The default value is 17

Table 6.139. Component identification parameters

NameValue
component-typeorg.richfaces.Gmap
component-classorg.richfaces.component.html.HtmlGmap
component-familyorg.richfaces.Gmap
renderer-typeorg.richfaces.GmapRenderer
tag-classorg.richfaces.taglib.GmapTag

6.46.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:gmap gmapKey="..."/>
...

6.46.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlGmap;
...
HtmlGmap myMap = new HtmlGmap();
...

6.46.5. Details of Usage

To use Google Map in your application, generate a key on Google Map official resource. One key could be used for one directory on the server.

Here are the main settings of initial rendering performed with a component map that are accessible with the following attributes:

  • "zoom" defines an approximation size (boundary values 1-18)
  • "lat" specifies an initial latitude coordinate in degrees, as a number between -90 and +90
  • "lng" specifies an initial longitude coordinate in degrees, as a number between -180 and +180
  • "mapType" specifies a type of a rendered map (G_NORMAL_MAP, G_SATELLITE_MAP (DEFAULT), G_HYBRID_MAP)

For example, the city of Paris is shown after rendering with the following initial settings: "lat" = 48.44, "lng" = 2.24 and "zoom" = 5.

Gmap initial rendering

Figure 6.44. Gmap initial rendering


It's also possible to set accessible controls on the map with the help of the attributes:

  • "showGMapTypeControl" determines whether the controls for a map type definition are switched on
  • "showGScaleControl" determines whether the controls for scaling are switched on
  • "showGLargeMapControl" determines whether the control for map scale rendering is rendered
Gmap accessible controls

Figure 6.45. Gmap accessible controls


To set all these parameters and perform some activity (Zoom In/Out etc.) is possible with your JavaScript, i.e. declare a name of an object on a map in the "gmapVar" attribute and then call the object directly with API Google Map.

For example, to approximate a map for "gmapVar" = "map" declared inside the component, call map.zoomIn() on an event.

Moreover, to add e.g. some JavaScript effects, events defined on it are used.

  • onmouseover
  • onclick
  • onmouseout
  • etc.

6.46.6. Look-and-Feel Customization

Gmap component isn't tied to skin parameters, as there is no additional elements on it, except the ones provided with Google Map.

6.46.7. Definition custom style classes

rich-gmap is a predefined style class for the map. It's possible to define some standard properties for all maps components on a page (padding, border, etc.) with the definition of the component.

6.46.8. Relevant resources links

Here you can see the example of <rich:gmap> usage and sources for the given example.

6.47.  < rich:virtualEarth >

6.47.1. Description

The component presents the Microsoft Virtual Earth map in the JSF applications.

virtualEarth component

Figure 6.46. virtualEarth component


6.47.2. Key Features

  • Presents the Microsoft Virtual Earth map functionality
  • Highly customizable via attributes
  • No developers JavaScript writing is needed to use it on a pages

Table 6.140. rich : virtualEarth attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dashboardSizeInitial map type. The possible values are Normal,Small,Tiny. The default value is Normal
idEvery component may have a unique id that is automatically created if omitted
latInitial latitude coordinate in degrees, as a number between -90 and +90
lngInitial longitude coordinate in degrees, as a number between -180 and +180
mapStyleNavigation control size. The possible values are Road,Aerial,Hybrid,Birdseye. The default value is Road
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onLoadMapJavaScript code invoked just after the Virtual Earth object is initiated.
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
varThe JavaScript variable that is used to access the Virtual Earth API. If you have more than one Virtual Earth components on the same page, use individual key for each of them. The default variable name is "map" (without quotes)
zoomInitial zoom level as a number between 1 and 18. The default value is 17

Table 6.141. Component identification parameters

NameValue
component-typeorg.richfaces.VirtualEarth
component-classorg.richfaces.component.html.HtmlVirtualEarth
component-familyorg.richfaces.VirtualEarth
renderer-typeorg.richfaces.VirtualEarthRenderer
tag-classorg.richfaces.taglib.VirtualEarthTag

6.47.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:virtualEarth lat="..." lng="..."/>
...

6.47.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlVirtualEarth;
...
HtmlVirtualEarth myMap = new HtmlVirtualEarth();
...

6.47.5. Details of Usage

Here are the main settings of initial rendering performed with a component map that are accessible with the following attributes:

  • "zoom" defines an approximation size (boundary values 1-18)
  • "lat" specifies an initial latitude coordinate in degrees, as a number between -90 and +90
  • "lng" specifies an initial longitude coordinate in degrees, as a number between -180 and +180
  • "dashboardSize" specifies a type of a rendered map (Normal, Small, Tiny)

For example, the city of Paris is shown after rendering with the following initial settings: "lat" = 48.833, "lng" = 2.40 and "zoom" = 11.

virtualEarth initial rendering

Figure 6.47. virtualEarth initial rendering


Code for this example is placed below:

Example:

...
    <rich:virtualEarth  style="width:800px;" id="vm" lat="48.833" lng="2.40" 
                                     dashboardSize="Normal"  zoom="11" mapStyle="Hybrid" var="map" />
...

To set all these parameters and perform some activity (Zoom In/Out etc.) is possible with your JavaScript, i.e. declare a name of an object on a map in the "var" attribute and then call the object directly with API Microsoft Virtual Earth map.

For example, to approximate a map for "var" = "map" declared inside the component, call map.ZoomIn() on an event.

Moreover, to add e.g. some JavaScript effects, events defined on it are used.

  • onmouseover
  • onclick
  • onmouseout
  • etc.

6.47.6. Look-and-Feel Customization

Virtual Earth map component isn't tied to skin parameters, as there is no additional elements on it, except the ones provided with Virtual Earth map.

6.47.7. Definition custom style classes

rich-virtualEarth map is a predefined style class for the map. It's possible to define some standard properties for all maps components on a page (padding, border, etc.) with the definition of the component.

6.47.8. Relevant resources links

Here you can found additional information about Microsoft Virtual Earth map.

6.48.  < rich:inputNumberSlider >

6.48.1. Description

A component that lets selecting a number from a numeric region. It's a horizontal aligned scroll-like control with its own input field (optional) present. The keyboard input in a field is possible (optional). Also it's possible to see the current value in the tooltip above a dragged handle control.

InputNumberSlider component

Figure 6.48. InputNumberSlider component


6.48.2. Key Features

  • Fully skinnable control and input elements
  • Optional value text field with an attribute-managed position
  • Optional disablement of the component on a page
  • Optional ToolTip to display the current value while a handle is dragged
  • Dragged state is stable after the mouse moves
  • Optional manual input possible if a text input field is present
  • Validation of manual input

Table 6.142. rich : inputNumberSlider attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
barClassA name of CSS class for the bar element
barStyleStyle for a slider control line
bindingThe attribute takes a value-binding expression for a component property of a backing bean
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
disabledWhen set for a form control, this boolean attribute disables the control for user input
enableManualInputFalse value for this attribute makes a text field "read-only", so the value can be changed only from a handle
handleClassA name of CSS class for a control handle element
handleSelectedClassA name of CSS class for a selected control handle element
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inputClassStyle Class attribute for a text field
inputPositionIf "right" the InputText Box would be rendered on the right side of the ruler
inputSizeSimilar to the "Size" attribute of h:inputText
inputStyleStyle attribute for text field
maxlengthWhen the type attribute has the value "text" or "password", this attribute specifies the maximum number of characters the user may enter. This number may exceed the specified size, in which case the user agent should offer a scrolling mechanism. The default value for this attribute is an unlimited number
maxValueAttribute to set an "end" value
minValueAttribute to set a "start" value
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onerrorThis error is called when a non-number value or a number value that is out of the range is input
onfocusHTML: script expression; the element got the focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; The onselect event occurs when a user selects some text in a text field. This attribute may be used with the INPUT and TEXTAREA elements
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
showBoundaryValuesIf the min/max values are shown on the right/left borders of a control. Default=true
showInputFalse value for this attribute makes text a field invisible
showToolTipIf the current value will be shown in the tooltip when a handle control in a "dragged" state.Default=true.
stepParameter that determines a step between the nearest values while using a handle
styleStyles for main div element of the slider control
styleClassName of a CSS class
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
tipClassA name of CSS class for the tool tip element
tipStyleA style for the tool tip element
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe initial value to set when rendered for the first time
valueChangeListenerListener for value changes
widthThe width of a slider control

Table 6.143. Component identification parameters

NameValue
component-typeorg.richfaces.inputNumberSlider
component-classorg.richfaces.component.html.HtmlInputNumberSlider
component-familyorg.richfaces.inputNumberSlider
renderer-typeorg.richfaces.InputNumberSliderRenderer
tag-classorg.richfaces.taglib.InputNumberSliderTag

6.48.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:inputNumberSlider minValue="0" maxValue="100" step="1"/>  
...

6.48.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlInputNumberSlider;
...
HtmlInputNumberSlider mySlider = new HtmlInputNumberSlider();
...

6.48.5. Details of Usage

<rich:inputNumberSlider> is used to facilitate your data input with rich UI Controls.

Here is the simplest variant of a slider definition with "minValue", "maxValue" and "step" (on default = "1") attributes, which define the beginning and the end of a numerical area and a slider property step.

Example:


<rich:inputNumberSlider></rich:inputNumberSlider>

It generates on a page:

Generated inputNumberSlider

Figure 6.49. Generated inputNumberSlider


Using "showInput" (default is true) and "enableManualInput" (default value is true) attributes, it's possible to output the input area near the slider, and make it read-only or editable.

To remove input area use "showInput="false" :

Example:


<rich:inputNumberSlider minValue="1"  maxValue="100" showInput="false"/>

It looks at page like:

InputNumberSlider without input field

Figure 6.50. InputNumberSlider without input field


It's also possible to switch off displaying of "boundary values" and a tooltip showing on a handle drawing. This could be performed with the help of the component defined attributes: "showBoundaryValues" which is responsible for "boundary values" displaying (default is true) and "showToolTip" which is responsible for tooltip displaying (default is true).

Moreover, to add e.g. some JavaScript effects, events defined on it are used.

  • onchange
  • onmouseover
  • onclick
  • onfocus
  • onmouseout
  • etc.

6.48.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all inputNumberSliders at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the inputNumberSlider to your page style sheets

6.48.7. Skin parameters redefinition

Table 6.144. Skin parameters redefinition for a bar

Skin parametersCSS properties
controlBackgroundColorbackground-color

Table 6.145. Skin parameters redefinition for numbers

Skin parametersCSS properties
generalFamilyFontfont-family
generalSizeFontfont-size
generalTextColorcolor
panelBorderColorborder-color
generalSizeFontline-height

Table 6.146. Skin parameters redefinition for a text field

Skin parametersCSS properties
controlBackgroundColorbackground-color
generalFamilyFontfont-family
generalSizeFontfont-size
controlTextColorcolor
panelBorderColorborder-color
subBorderColorborder-bottom-color
subBorderColorborder-right-color

Table 6.147. Skin parameters redefinition for a hint

Skin parametersCSS properties
tipBackgroundColorbackground-color
tipBorderColorborder-color
generalFamilyFontfont-family
generalSizeFontfont-size

6.48.8. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Style classes

Figure 6.51. Style classes


Table 6.148. Classes names that define a component appearance

Class nameDescription
rich-sliderDefines styles for a wrapper table element of the component
rich-inslider-trackDefines styles for a bar
rich-inslider-handlerDefines styles for a slider handler
rich-inslider-handler-selectedDefines styles for a selected handler
rich-inslider-fieldDefines styles for a text field
rich-inslider-right-numDefines styles for the right number
rich-inslider-left-numDefines styles for the left number
rich-inslider-tipDefines styles for a hint

It's necessary only to define a class according to the corresponding name, so as an appearance of all sliders on a page is changed at once.

To redefine appearance of particular sliders, it's possible to define your own CSS class with one of the names listed there. And then just define one of the components class attributes modifying component style properties.

Example:

CSS code piece used on a page:

Example:

...
    .rich-slider-handle{
        border:2px solid;
    }
    .myClass{
        font-style:italic;
    }
...

The component is defined in the following way:

Example:


<rich:inputNumberSlider ... inputClass="myClass" .../>

Hence, header border width of all sliders is redefined on a page as well as a style font for an input field of a particular slider.

6.48.9. Relevant resources links

Here you can see the example of <rich:inputNumberSlider> usage and sources for the given example.

6.49.  < rich:inputNumberSpinner >

6.49.1. Description

A single line input field that lets selecting a number using controls near a text field. It's possible to change a value using "Up/Down" keyboard keys. The keyboard input in a field is possible if it isn't locked by the "manualInput" attribute. When arrow controls are pressed, the cursor can be moved in any way without losing a dragged state.

InputNumberSpinner component

Figure 6.52. InputNumberSpinner component


6.49.2. Key Features

  • Fully skinnable control and input elements
  • 3D look and feel with an easily customizable appearance
  • Attribute-managed positions of the controls (inside/outside of the input field)
  • Keyboard controls support
  • Optional disablement of the component on a page
  • Optional "cycled" mode of scrolling values
  • Optional manual/controls-only input into a value text field
  • Validation of manual input

Table 6.149. rich : inputNumberSpinner attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
bindingThe attribute takes a value-binding expression for a component property of a backing bean
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
cycledIf "true" after the current value reaches the border value it is reversed to another border value after next increasing/decreasing. In other case possibilities of next increasing (or decreasing) will be locked
disabledWhen set for a form control, this boolean attribute disables the control for user input
enableManualInputif "false" user's input to the text field using keyboard will be locked
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inputClassClass attribute for text field
inputSizeAttribute specifies the initial length of input in characters. Default value is 10
inputStyleStyle attribute for text field
maxValueMaximum value
minValueMinimum value
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
ondownclickHTML: a script expression; a button "Down" is clicked
onerrorHTML: a script expression; event fires whenever an JavaScript error occurs
onfocusHTML: script expression; the element got the focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; The onselect event occurs when a user selects some text in a text field. This attribute may be used with the INPUT and TEXTAREA elements
onupclickHTML: a script expression; a button "Up" is clicked
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
stepParameter that determines the step between nearest values while using controls
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe initial value to set when rendered for the first time
valueChangeListenerListener for value changes

Table 6.150. Component identification parameters

NameValue
component-typeorg.richfaces.inputNumberSpinner
component-classorg.richfaces.component.html.HtmlInputNumberSpinner
component-familyorg.richfaces.inputNumberSpinner
renderer-typeorg.richfaces.InputNumberSpinnerRenderer
tag-classorg.richfaces.taglib.InputNumberSpinnerTag

6.49.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:inputNumberSpinner minValue="0" maxValue="100" step="1"/> 
...

6.49.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlInputNumberSpinner;
...
HtmlInputNumberSpinner mySpinner = new HtmlInputNumberSpinner ();
...

6.49.5. Details of Usage

<rich:inputNumberSpinner> is used to facilitate your data input with rich UI Controls.

Here is the simplest variant of spinner definition with "minValue", "maxValue" and "step" (on default = "1") attributes, which define the beginning and the end of numerical area and a spinner step.

Example:


...
    <rich:inputNumberSpinner minValue="1" maxValue="100"/>
...

It generates on a page:

Generated inputNumberSpinner

Figure 6.53. Generated inputNumberSpinner


There are also several attributes to define functionality peculiarities:

  • "cycled" if the attribute is "true" after the current value reaches the border value it's be reversed to another border value after next increasing/decreasing. In other case possibilities of next increasing/decreasing are locked
  • "disabled" is an attribute that defines whether a component is active on a page
  • "manualInput" is an attribute that defines whether a keyboard input is possible or only UI controls could be used

Moreover, to add e.g. some JavaScript effects, events defined on it are used

  • onchange
  • onmouseover
  • onclick
  • onfocus
  • onmouseout
  • etc.

6.49.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all inputNumberSpinners at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the inputNumberSpinner to your page style sheets

6.49.7. Skin parameters redefinition

Table 6.151. Skin parameters redefinition for a container

Skin parametersCSS properties
controlBackgroundColorbackground-color
panelBorderColorborder-color
subBorderColorborder-bottom-color
subBorderColorborder-right-color

Table 6.152. Skin parameters redefinition for an input field

Skin parametersCSS properties
buttonSizeFontfont-size
buttonFamilyFontfont-family

6.49.8. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Style classes

Figure 6.54. Style classes


Table 6.153. Classes names that define a component appearance

Class nameDescription
rich-spinner-cDefines styles for a wrapper table element of the component
rich-spinner-input-containerDefines styles for a container
rich-spinner-inputDefines styles for an input field
rich-spinner-buttonDefines styles for a button

It's necessary only to define a class according to the corresponding name, so as an appearance of all spinners on a page is changed at once.

To redefine appearance of the particular spinner, it's possible to define your own CSS class. Then it's necessary just to define it in one of the "components class" attributes modifying component style properties.

Example:

CSS code piece used on a page:

Example:


...
    . rich-spinner-input {
            font-style:italic;
        }
    .myClass {
            font-weight: bold;
        }
...

The component is defined in the following way:

Example:


<rich:inputNumberSpinner inputClass="myClass" .../>

Hence, a font-style of all spinners is redefined on a page as well as a font-weight for an entry field of the particular spinner.

6.49.9. Relevant resources links

Here you can see the example of <rich:inputNumberSpinner> usage and sources for the given example.

6.50.  < rich:insert >

6.50.1. Description

The <rich:insert> component is used for highlighting, source code inserting and, optionally, format the file from the application context into the page.

6.50.2. Key Features

  • Source code highlighting
  • Variety of formats for source code highlighting

Table 6.154. rich : insert attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
encodingAttribute defines encoding for inserted content
errorContentAttribute defines the alternative content that will be shown in case component cannot read the resource defined with 'src' attribute. If "errorContent" attribute is not defined, the component shown the actual error message in the place where the content is expected
highlightDefines a type of code
idEvery component may have a unique id that is automatically created if omitted
renderedIf "false", this component is not rendered
srcDefines the path to the file with source code

Table 6.155. Component identification parameters

NameValue
component-typeorg.richfaces.ui.Insert
component-classorg.richfaces.ui.component.html.HtmlInsert
component-familyorg.richfaces.ui.Insert
renderer-typeorg.richfaces.ui.InsertRenderer
tag-classorg.richfaces.ui.taglib.InsertTag

6.50.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

Example:


...
      <rich:insert  src="/pages/sourcePage.xhtml" highlight="xhtml"/>
...

6.50.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.ui.component.html.HtmlInsert;  
...
HtmlInsert myInsert = new HtmlInsert();
...

6.50.5. Details of Usage

The are two basic attributes. The "src" attribute defines the path to the file with source code. The "highlight" attribute defines the type of a syntax highlighting.

If "highlight" attribute is defined and JHighlight open source library is in the classpath, the text from the file will be formated and colorized.

An example is placed below.

Example:


...
      <rich:insert  src="/pages/sourcePage.xhtml" highlight="xhtml"/>
...

The result of using <rich:insert> component is shown on the picture:

Source code highlighting

Figure 6.55. Source code highlighting


The <rich:insert> component provides the same functionalitity as JHighlight. Thus, all names of highlight style classes for source code of particular language could be changed to your names, wich are used by the JHighlight library.

6.50.6. Relevant resources links

Here you can see the example of <rich:insert> usage and sources for the given example.

6.51.  < rich:message >

6.51.1. Description

The component used for rendering a single message for a specific component.

Message component

Figure 6.56. Message component


6.51.2. Key Features

  • Highly customizable look and feel
  • Track both traditional and Ajax based requests
  • Optional tooltip to display the detail portion of the message
  • Additionally customizable via attributes and facets
  • Additionally provides of two parts to be optionally defined: marker and label

Table 6.156. rich : message attributes

Attribute NameDescription
ajaxRenderedDefine, must be (or not) content of this component will be included in AJAX response created by parent AJAX Container, even if not forced by reRender list of ajax action. ignored if component marked to output by Ajax action.
bindingThe attribute takes a value-binding expression for a component property of a backing bean
errorClassCSS style class to apply to any message with a severity class of "ERROR"
errorLabelClassCSS style class to apply to any message label with a severity class of "ERROR"
errorMarkerClassCSS style class to apply to any message marker with a severity class of "ERROR"
fatalClassCSS style class to apply to any message with a severity class of "FATAL"
fatalLabelClassCSS style class to apply to any message label with a severity class of "FATAL"
fatalMarkerClassCSS style class to apply to any message marker with a severity class of "FATAL"
forClient identifier of the component for which to display messages
idEvery component may have a unique id that is automatically created if omitted
infoClassCSS style class to apply to any message with a severity class of "INFO"
infoLabelClassCSS style class to apply to any message label with a severity class of "INFO"
infoMarkerClassCSS style class to apply to any message marker with a severity class of "INFO"
keepTransientFlag for mark all child components to non-transient. If "true", all children components will be set to non-transient state and keep in saved components tree. For output in self-renderer region all content (By default, all content in <f:verbatim> tags and non-jsf elements in facelets, marked as transient - since, self-rendered ajax regions don't plain output for ajax processing).
labelClassCSS style class to apply to label
markerClassCSS style class to apply to marker
markerStyleCSS style(s) is/are to be applied to marker when this component is rendered
passedLabelAttribute should define the label to be displayed when no message appears
renderedIf "false", this component is not rendered
showDetailFlag indicating whether the summary portion of displayed messages should be included. Default value is "true"
showSummaryFlag indicating whether the summary portion of displayed messages should be included. Default value is "false"
styleThe CSS style for message
styleClassSpace-separated list of CSS style class(es) to be applied when this element is rendered. This value must be passed through as the "class" attribute on generated markup
titleAdvisory title information about markup elements generated for this component
tooltipFlag indicating whether the detail portion of the message should be displayed as a tooltip
warnClassCSS style class to apply to any message with a severity class of "WARN"
warnLabelClassCSS style class to apply to any message label with a severity class of "WARN"
warnMarkerClassCSS style class to apply any message marker with a severity class of "WARN"

Table 6.157. Component identification parameters

NameValue
component-typeorg.richfaces.component.RichMessage
component-classorg.richfaces.component.html.HtmlRichMessage
component-familyorg.richfaces.component.RichMessage
renderer-typeorg.richfaces.renderkit.html.RichMessagesHtmlBaseRenderer
tag-classorg.richfaces.taglib.RichMessageTag

6.51.3. Creating the Component with a Page Tag

To create the simplest variant of message on a page, use the following syntax:

Example:


...
    <rich:message for="id"/>
...

6.51.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlRichMessage;
...
HtmlRichMessage myMessage = new HtmlRichMessage();
...

6.51.5. Details of Usage

The component has the same behavior as standard <h:message> component except next two features:

  • It's ajaxRendered. It means that the component is reRendered after Ajax request automatically without outputPanel usage
  • The component optionally provides "passed" state which will be shown if no message to be displayed
  • Provides possibility to add some marker to message. By default marker element isn't shown

Set of facet which can be used for marker defining:

  • passedMarker. This facet is provided to allow set a marker to be displayed if there is no message
  • errorMarker. This facet is provided to allow set a marker to be displayed if there is a message with a severity class of "ERROR"
  • fatalMarker. This facet is provided to allow set a marker to be displayed if there is a message with a severity class of "FATAL"
  • infoMarker. This facet is provided to allow set a marker to be displayed if there is a message with a severity class of "INFO"
  • warnMarker. This facet is provided to allow set a marker to be displayed if there is an message with a severity class of "WARN"

The following example shows different variants of customization of the component. The attribute 'passedLabel' is used for definition the label to be displayed when no message appears. But the message component isn't appears before the form submission even with passed state defined (on initial rendering).Boolean attribute "showSummary" defines possibility to display summary portion of displayed messages. The facets "errorMarker" and 'passedMarker' set corresponding images for markers.

Example:


...
        <rich:message for="id" passedLabel="No errors' showSummary="true">
            <f:facet name="errorMarker">
                <h:graphicImage url="/image/error.gif"/>
            </f:facet>
            <f:facet name="passedMarker">
                <h:graphicImage url="/image/passed.gif"/>
            </f:facet>      
        </rich:message>     
...

6.51.6. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

To redefine appearance of all <rich:message> components, you may define the properties of the predefined style classes in the common CSS style sheet used on a page (there are no skin parameters and predefined values by default to make it compatible with the standard message component).

6.51.7. Definition of Custom Style Classes

Classes names

Figure 6.57. Classes names


On the screenshot, there are classes names defining specified elements.

Table 6.158. Component skin class

Class nameDescription
rich-messageDefines the class for wrapper element
rich-message-markerDefines the class for marker element
rich-message-labelDefines the class for label element

In order to redefine the style for <rich:message> components on a page using CSS, it's enough to create classes with the same names and define the necessary properties in them.

To change the style of particular <rich:message> components define your own style classes in the corresponding message attributes.

6.51.8. Relevant resources links

Here you can see the example of <rich:message> usage and sources for the given example.

6.52.  < rich:messages >

6.52.1. Description

The <rich:messages> component is similar to <rich:message> component but used for rendering all messages for the components.

Message component

Figure 6.58. Message component


6.52.2. Key Features

  • Highly customizable look and feel
  • Track both traditional and Ajax based requests
  • Optional tooltip to display a detailed part of the messages
  • Additionally customizable via attributes and facets
  • Additionally provides of three parts to be optionally defined: marker, label and header

Table 6.159. rich : messages attributes

Attribute NameDescription
ajaxRenderedDefine, must be (or not) content of this component will be included in AJAX response created by parent AJAX Container, even if not forced by reRender list of ajax action. ignored if component marked to output by Ajax action.
bindingThe attribute takes a value-binding expression for a component property of a backing bean
errorClassCSS style class to apply to any message with a severity class of "ERROR"
errorLabelClassCSS style class to apply to any message label with a severity class of "ERROR"
errorMarkerClassCSS style class to apply to any message marker with a severity class of "ERROR"
fatalClassCSS style class to apply to any message with a severity class of "FATAL"
fatalLabelClassCSS style class to apply to any message label with a severity class of "FATAL"
fatalMarkerClassCSS style class to apply to any message marker with a severity class of "FATAL"
globalOnlyFlag indicating that only global messages (that is, messages not associated with any client identifier) are to be displayed. Default value is "false"
idEvery component may have a unique id that is automatically created if omitted
infoClassCSS style class to apply to any message with a severity class of "INFO"
infoLabelClassCSS style class to apply to any message label with a severity class of "INFO"
infoMarkerClassCSS style class to apply to any message marker with a severity class of "INFO"
keepTransientFlag for mark all child components to non-transient. If "true", all children components will be set to non-transient state and keep in saved components tree. For output in self-renderer region all content (By default, all content in <f:verbatim> tags and non-jsf elements in facelets, marked as transient - since, self-rendered ajax regions don't plain output for ajax processing).
labelClassCSS style class to apply to label
layoutThe type of layout markup to use when rendering error messages. Valid values are "table" (an HTML table), "list" (an HTML list) and iterator. If not specified, the default value is "list"
markerClassCSS style class to apply to marker
markerStyleCSS style(s) is/are to be applied to marker when this component is rendered
passedLabelAttribute should define the label to be displayed when no message appears
renderedIf "false", this component is not rendered
showDetailFlag indicating whether the summary portion of displayed messages should be included. Default value is "true"
showSummaryFlag indicating whether the summary portion of displayed messages should be included. Default value is "false"
styleThe CSS style for message
styleClassSpace-separated list of CSS style class(es) to be applied when this element is rendered. This value must be passed through as the "class" attribute on generated markup
titleAdvisory title information about markup elements generated for this component
tooltipFlag indicating whether the detail portion of the message should be displayed as a tooltip
varName of a request-scope attribute under which the list of the messages should be available
warnClassCSS style class to apply to any message with a severity class of "WARN"
warnLabelClassCSS style class to apply to any message label with a severity class of "WARN"
warnMarkerClassCSS style class to apply any message marker with a severity class of "WARN"

Table 6.160. Component identification parameters

NameValue
component-typeorg.richfaces.component.RichMessages
component-classorg.richfaces.component.html.HtmlRichMessages
component-familyorg.richfaces.component.RichMessages
renderer-typeorg.richfaces.renderkit.html.HtmlRichMessagesRendere
tag-classorg.richfaces.taglib.RichMessagesTag

6.52.3. Creating the Component with a Page Tag

To create the simplest variant of message on a page, use the following syntax:

Example:


...
    <rich:messages/>
...

6.52.4. Creating the Component Dynamically Using Java

Example:


import  org.richfaces.component.html.HtmlRichMessages;
...
HtmlRichMessages myMessages = new HtmlRichMessages();
...

6.52.5. Details of Usage

The component has the same behavior as standard <h:message> component except next features:

  • It's ajaxRendered. It means that the component is reRendered after Ajax request automatically without outputPanel usage.
  • The component optionally provides "passed" state which will be shown if no message to be displayed.
  • Provides possibility to add some marker to message. By default, a marker element isn't shown.

The component provides two parts to be optionally defined: marker and informational label before the marker for every message.

Set of facet which can be used for a marker defining:

  • passedMarker. This facet is provided to allow setting a marker to be displayed if there is no message.
  • errorMarker. This facet is provided to allow setting a marker to be displayed if there is a message with a severity class of "ERROR".
  • fatalMarker. This facet is provided to allow setting a marker to be displayed if there is a message with a severity class of "FATAL".
  • infoMarker. This facet is provided to allow setting a marker to be displayed if there is a message with a severity class of "INFO".
  • warnMarker. This facet is provided to allow setting a marker to be displayed if there is an message with a severity class of "WARN".

The following example shows different variants of customization of the component.

Example:


...
    <rich:messages layout="table" tooltip="true" showDetail="false" showSummary="true" passedLabel="No Errors" var="messages">
        <f:facet name="errorMarker">
            <h:graphicImage url="/image/error.gif"/>
        </f:facet>
        <f:facet name="infoMarker">
            <h:graphicImage url="/image/info.gif"/>
        </f:facet>
        <f:facet name="passedMarker">
            <h:graphicImage url="/image/passed.gif"/>
        </f:facet> 
    </rich:messages>
...

6.52.6. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

To redefine appearance of all <rich:messages> components, you can define the properties of the predefined style classes in the common CSS style sheet used on a page (there are no skin parameters and predefined values by default to make it compatible with the standard message component).

6.52.7. Definition of Custom Style Classes

Classes names

Figure 6.59. Classes names


On the screenshot, there are classes names defining specified elements.

Table 6.161. Component skin class

Class nameDescription
rich-messagesDefines styles for outer element
rich-messages-markerDefines styles for icon element
rich-messages-labelDefines styles for informational label element

In order to redefine the style for <rich:message> components on a page using CSS, it's enough to create classes with the same names and define the necessary properties in them.

To change the style of particular <rich:messages> components define your own style classes in the corresponding <rich:messages> attributes.

6.52.8. Relevant resources links

Here you can see the example of <rich:messages> usage and sources for the given example.

6.53.  < rich:modalPanel >

6.53.1. Description

The component implements a modal dialog window. All operations in the main application window are locked out while this window is active. Opening and closing the window is done through client JavaScript code.

ModalPanel component

Figure 6.60. ModalPanel component


6.53.2. Key Features

  • Highly customizable look and feel
  • Support of draggable operations and size changes by you
  • Easy positioning for the modal dialog window
  • Possibility to restore of the previous component state on a page (including position on the screen) after submitting and reloading

Table 6.162. rich : modalPanel attributes

Attribute NameDescription
autosizedIf 'true' modalPanel should be autosizeable
bindingThe attribute takes a value-binding expression for a component property of a backing bean
controlsClassCSS style(s) is/are to be applied to component controls when this component is rendered
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
headerClassCSS style(s) is/are to be applied to component header when this component is rendered
heightAttribute defines height of component
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
keepVisualStateIf "true" modalPanel should save state after submittion
leftAttribute defines X position of component left-top corner
minHeightAttribute defines min height of component
minWidthAttribute defines min width of component
moveableif "true" there is possibility to move component
onhideEvent must occurs after panel closed
onshowEvent must occurs after panel opened
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
resizeableif "true" there is possibility to change component size
shadowDepthPop-up shadow depth for suggestion content
shadowOpacityHTML CSS class attribute of element for pop-up suggestion content
showWhenRenderedIf "true" value for this attribute makes a modal panel opened as default.
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
topAttribute defines Y position of component left-top corner
tridentIVEngineSelectBehaviorHow to handle HTML SELECT-based controls in IE 6? - "disable" - default, handle as usual, use disabled="true" to hide SELECT controls - "hide" - use visibility="hidden" to hide SELECT controls
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe initial value to set when rendered for the first time
valueChangeListenerListener for value changes
visualOptionsDefines options that were specified on the client side
widthAttribute defines width of component
zindexAttribute is similar to the standard HTML attribute and can specify window placement relative to the content

Table 6.163. Component identification parameters

NameValue
component-typeorg.richfaces.ModalPanel
component-classorg.richfaces.component.html.HtmlModalPanel
component-familyorg.richfaces.ModalPanel
renderer-typeorg.richfaces.ModalPanelRenderer
tag-classorg.richfaces.taglib.ModalPanelTag

6.53.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:modalPanel id="panel">
        <f:facet name="header">
            <h:outputText value="header">
        </f:facet>
        ...
        <!--Any Content inside-->
        ...
        <a href="javascript:RichFaces.hideModalPanel('form:panel')">Hide</a>
    </rich:modalpanel>
...
    <a href="javascript:RichFaces.showModalPanel('form:panel')">Show</a>
...

6.53.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlModalPanel;
...
HtmlModalPanel myPanel = new HtmlModalPanel();
...

6.53.5. Details of Usage

The component is defined as a panel with some content inside that displays its content as a modal dialog. To call it and to close it, the client API for the window is used.

Table 6.164. Functions description

FunctionDescription
RichFaces.showModalPanel (client Id)Opens a window with a specified client Id
RichFaces.hideModalPanel (client Id)Closes a window with a specified client Id

New:

In order to avoid a bug in IE, the root node of the dialog is moved on the top of a DOM tree. However, you should have a separate form inside the modal panel if you want to perform submits from this panel.

It's possible to add a "header" facet to the component to set the content for the header.

Example:


...
    <form jsfc="h:form" id="form">
        <rich:modalPanel id="panel" width="400" height="300">
            <f:facet name="header">
                <h:outputText value="Modal Panel"/>
            </f:facet>
        <h:graphicImage value="/pages/california_large.gif"/>
        <a href="javascript:Richfaces.hideModalPanel('form:panel')">Close</a>
        </rich:modalPanel>
        <a href="javascript:Richfaces.showModalPanel('form:panel');">Open</a>
    </form>
...

This defines a window with a particular size and ID. It includes one "Open" link. Clicking on this link makes the modal window content appear.

ModalPanel with links

Figure 6.61. ModalPanel with links


A facet named "controls" can be added to the component to place control elements on a header.

Example:


...
    <rich:modalPanel id="panel">
        <f:facet name="header"><h:outputText value="Modal Panel"/></f:facet>
        <f:facet name="controls">
            <a href="javascript:Richfaces.hideModalPanel('form:panel')">X</a>
        </f:facet>
        <h:graphicImage value="/pages/california_large.gif"/>
    </rich:modalPanel>

The result displays like this:

ModalPanel with control element

Figure 6.62. ModalPanel with control element


To manage the placement of inserted windows, use the "zindex" attribute that is similar to the standard HTML attribute and can specify window placement relative to the content.

To manage window placement relative to the component, there are "left" and "top" attributes defining a window shifting relative to the top-left corner of the window.

Modal windows can also support resize and move operations on the client side. To allow or disallow these operations, set the "resizeable" and "moveable" attributes to "true" or "false" values. Window resizing is also limited by "minWidth" and "minHeight" attributes specifying the minimal window sizes.

You can pass your parameters during modalPanel opening or closing. This passing could be performed in the following way:

Example:


Richfaces.showModalPanel('panelId', {left: auto}, {param1: value1});
    

Thus, except the standard modalPanel parameters you can pass any of your own parameters.

Also modalPanel allows to handle its own opening and closing events on the client side. The "onshow" and "onclose" attributes are used in this case.

The following example shows how on the client side to define opening and closing event handling in such a way that your own parameters could also be obtained:

Example:


onshow="alert(event.parameters.param1)"

Here, during modalPanel opening the value of a passing parameter is output.

More information about this problem could be found on the RichFaces Development Forum.

There is a possibility to restore of the previous component state on a page (including position on the screen) after submitting and reloading. The modalPanel has some special attributes like "showWhenRendered" and "keepVisualState" .

"showWhenRendered" - This boolean attribute is used if modalPanel should be rendered after first page loading.

"keepVisualState" - Used if modalPanel should save state after submission. If "keepVisualState" =true then parameters which modalPanel has during opening should be submitted and passed to new page.

Example:


...
<a href="javascript:Richfaces.showModalPanel('_panel', {top:'10px', left:'10px', height:'400'});">Show</a>
...
    

Here, if you open modal dialog window using current link and after submits data then modalPanel destination and height on new loaded page will be restored.

if you need the content of the modalPanel to be submitted - you need to remember two important rules:

  • modalPanel must have its own form if it has form elements (input or/and command components) inside (as it was shown in the example above)
  • modalPanel must not be included into the form (on any level up) if it has the form inside.

Simple example of using commandButton within modalPanel is placed below.

Example:


...
        <rich:modalPanel> 
                <f:facet name="header"> 
                        <h:outputText value="Test" /> 
                </f:facet> 
                <f:facet name="controls"> 
                        <h:commandLink value="Close" style="cursor:pointer" onclick="Richfaces.hideModalPanel('mp')" /> 
                </f:facet> 
                <h:form> 
                        <t:commandButton value="Test" action="#{TESTCONTROLLER.test}" /> 
                </h:form> 
        </rich:modalPanel>
        ...
        <h:form> 
                <!--Some other Page content-->
        </h:form>
...        

See also discussion about this problem on the RichFaces Users Forum.

6.53.6. Look-and-Feel Customization

For implementing skinnability the components use a style class redefinition method . Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all modal panels at once:

  • Redefine the corresponding skin parameters
  • Add style classes used by modalPanel to your page style sheets

6.53.7. Skin Parameters Redefinition

Table 6.165. Panel skin parameters

Panel skin parametersProperties corresponding to CSS parameter
generalBackgroundColorbackground-color
panelBorderColorborder-color

Table 6.166. Header parameters

Headers parametersProperties corresponding to CSS parameter
headerBackgroundColorbackground-color
headerBackgroundColorborder-color

Table 6.167. Header content parameters

Headers content parametersProperties corresponding to CSS parameter
headerSizeFontbackground-color
headerTextColorfont-size
headerWeightFontcolor
headerFamilyFontfont-family

Table 6.168. Body parameters

Body parametersProperties corresponding to CSS parameter
generalSizeFontfont-size
generalTextColorcolor
generalFamilyFontfont-family

6.53.8. Definition custom style classes

Modal Panel class names

Figure 6.63. Modal Panel class names


The screenshot shows the classes names for defining different elements.

Table 6.169. Class names

rich-mpnl-pnl-hThis class defines the header style. It's applied to the header elements of all panels.
rich-mpnl-pnl-textThis class defines the header content style. It's applied to the header elements of all panels.
rich-mpnl-pnl-bodyThis class defines the style for the content inside a panel. It's applied to the elements inside panels.
generalFamilyFontfont-family

6.53.9. Relevant resources links

Here you can see the example of <rich:modalPanel> usage and sources for the given example.

Information about wizards using the <rich:modalPanel> component could be found in the Wiki article and in the FAQ chapter of the guide.

Examples of validation in <rich:modalPanel> could be found in the Wiki article and on the RichFaces Users Forum.

6.54.  < rich:paint2D >

6.54.1. Description

Create image by painting from a managed bean method, same as "paint" (Graphics2D) in "SWING" components.

Paint2D component

Figure 6.64. Paint2D component


6.54.2. Key Features

  • Simple Graphics2D - painting style directly on the Web page
  • Supports client/server caching for generated images
  • Fully supports "JPEG" (24-bit, default), "GIF" (8-bit with transparency), and "PNG" (32-bit with transparency) formats for sending generated images
  • Easily customizable borders and white space to wrap the image
  • Dynamically settable paint parameters using tag attributes

Table 6.170. rich : paint2D attributes

Attribute NameDescription
alignbottom|middle|top|left|right Deprecated. This attribute specifies the position of an IMG, OBJECT, or APPLET with respect to its context. The following values for align concern the object's position with respect to surrounding text: * bottom: means that the bottom of the object should be vertically aligned with the current baseline. This is the default value. * middle: means that the center of the object should be vertically aligned with the current baseline. * top: means that the top of the object should be vertically aligned with the top of the current text line
bgcolorBackground color of painted image. Default value is 'transparent' which means no background fill. Hex colors can be used, as well as common color names. Invalid values are treated as transparent. Note, that JPEG format doesn't support transparency, and transparent background is painted black. Also note, that several browsers (e.g. IE6) do not support PNG transparency
bindingThe attribute takes a value-binding expression for a component property of a backing bean
borderDeprecated. This attribute specifies the width of an IMG or OBJECT border, in pixels. The default value for this attribute depends on the user agent
cacheableSupported (or not) client/server caching for generated images. Caching on client supported by properly sending and processing of HTTP headers (Last-Modified, Expires, If-Modified-Since, etc.) Server-side caching is supported by application-scope object cache. For build of cache key use "value" attribute, serialized to URI
converterId of Converter to be used or reference to a Converter
dataValue calculated at render time and stored in Image URI (as part of cache Key), at paint time passed to a paint method. It can be used for updating cache at change of image generating conditions, and for creating paint beans as "Lightweight" pattern components (request scope). IMPORTANT: Since serialized data stored in URI, avoid using big objects
formatformat Name of format for sending a generated image. It currently supports "jpeg" (24 bit, default), "gif" (8 bit with transparency), "png" (32 bit with transparency)
heightHeight in pixels of image (for paint canvas and HTML attribute)
hspaceDeprecated. This attribute specifies the amount of white space to be inserted to the left and right of an IMG, APPLET, or OBJECT. The default value is not specified, but is generally a small, non-zero length
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
paintThe method calls expression to paint Image on prepared Buffered image. It must have two parameters with a type of java.awt.Graphics2D (graphics to paint) and Object (restored from URI "data" property). For painting used 32-bit RGBA color model (for 8-bit images used Diffusion filtration before sending)
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
valueThe initial value to set when rendered for the first time
vspaceDeprecated. This attribute specifies the amount of white space to be inserted above and below an IMG, APPLET, or OBJECT. The default value is not specified, but is generally a small, non-zero length
widthWidth in pixels of image (for paint canvas and HTML attribute)

Table 6.171. Component identification parameters

NameValue
component-typeorg.richfaces.Paint2D
component-classorg.richfaces.component.html.HtmlPaint2D
component-familyjavax.faces.Output
renderer-typeorg.richfaces.Paint2DRenderer
tag-classorg.richfaces.taglib.Paint2DTag

6.54.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:paint2D paint="#{paint2D.paint}" data="#{paint2DModel}"/>
...

Here "paint" specifies the method performing drawing and "data" specifies Managed Bean property keeping the data used by the method.

6.54.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlPaint2D;
...
HtmlPaint2D myImage = new HtmlPaint2D();
...

6.54.5. Details of Usage

The example shows two main attributes of the component:

  • "paint"

    Specify a method receiving an object specified in data as a parameter and sending graphical information into the stream

  • "data"

    Specifies a bean class keeping your data for rendering

Note:

data object should implement serializable interface

The "format" attribute of the component defines a format of visual data passing to the server.

Generated data can be used as a cacheable or non-cacheable resource. It's defined with "cacheable" attribute. If cache support is turned on, a key is created in URI with a mix of size (width/height), "paint" method, "format" and "data" attributes.

Example:

Example:


paintBean.java:

    public void paint(Graphics2D g2, Object obj) {
        // code that gets data from the data Bean (PaintData)
        PaintData data = (PaintData) obj;
        ...
        // a code drawing a rectangle
        g2.drawRect(0, 0, data.Width, data.Height);
        ...      
        // some more code placing graphical data into g2 stream below
    }

dataBean.java:

    public class PaintData implements Serializable{
        private static final long serialVersionUID = 1L;
        Integer Width=100;
        Integer Height=50;
        ...
    }

page.xhtml:
...
    <rich:paint2D paint="#{paint2D.paint}" data="#{paint2DModel.data}"/>
... 

6.54.6. Look-and-Feel Customization

Paint2D has no skin parameters and special style classes, as it consists of one element generated with a your method on the server.

To define some style properties such as an indent or a border, it's possible to use "style" and "styleClass" attributes on the component.

6.54.7. Relevant resources links

Here you can see the example of <rich:paint2D> usage and sources for the given example.

6.55.  < rich:panel >

6.55.1. Description

A skinnable panel that is rendered as a bordered rectangle with or without a header.

Panel component

Figure 6.65. Panel component


6.55.2. Key Features

  • Highly customizable look and feel
  • Support for any content inside
  • Header adding feature

Table 6.172. rich : panel attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bodyClassA class that defines a style for a panel content
headerLabel text appears on a panel header
headerClassA class that defines a style for a panel header
idEvery component may have a unique id that is automatically created if omitted
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute

Table 6.173. Component identification parameters

NameValue
component-typeorg.richfaces.panel
component-classorg.richfaces.component.html.HtmlPanel
component-familyorg.richfaces.panel
renderer-typeorg.richfaces.PanelRenderer
tag-classorg.richfaces.taglib.PanelTag

6.55.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:panel header="Panel Header">
        ...
        <!--Any Content inside-->
        ...
    </rich:panel>
...

6.55.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlPanel;
...
HtmlPanel myPanel = new HtmlPanel();
...

6.55.5. Details of Usage

The "header" attribute defines text to be represented. If you can use the "header" facet, you can even not use the "header" attribute.

Example:

...
    <rich:panel>
        <f:facet name="header">  
            <h:graphicImage value="/images/img1.gif"/>
        </f:facet>
        ...
        <!--Any Content inside-->
        ...
    </rich:panel>
...

<rich:panel> components are used to group page content pieces on similarly formatted rectangular panels.

Example:


...
    <rich:panel>
        ...
    </rich:panel>
...

It's generating on a page in the following way:

Generated panel without header

Figure 6.66. Generated panel without header


The example shows that similar rectangular areas are formed with a particular style.

When creating a panel with a header element, one more <div> element is added with content defined for a header.

Example:


...
    <rich:panel>
        <f:facet name="header">
            <h:outputText value="Olympus EVOLT E-500 "/>
        </f:facet>
        ...
    </rich:panel>
...

It's displayed on a page in the following way:

Panel with header

Figure 6.67. Panel with header


As it has been mentioned above, the component is mostly used for a page style definition, hence the main attributes are style ones.

  • "styleClass" and "style"
  • "headerClass" and "headerStyle"
  • "bodyClass" and "bodyStyle"

Moreover, to add e.g. some JavaScript effects, events defined on it are used.

  • "onmouseover"
  • "onclick"
  • "onmouseout"
  • etc.

6.55.7. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method.

Default style classes are mapped on skin parameters.

To redefine appearance of all panels at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the panel to your page style sheets

6.55.8. Skin parameters redefinition

Table 6.174. Skin parameters for the panel

Skin parametersCSS properties
generalBackgroundColorbackground-color
panelBorderColorborder-color

Table 6.175. Parameters for a header element

Skin parametersCSS properties
headerBackgroundColorbackground-color
headerBackgroundColorborder-color
headerSizeFontfont-size
headerTextColorcolor
headerWeightFontfont-weight
headerFamilyFontfont-family

Table 6.176. Parameters for a body element

Skin parametersCSS properties
generalSizeFontfont-size
generalTextColorcolor
generalFamilyFontfont-family

6.55.9. Definition custom style classes

Style classes of panel

Figure 6.68. Style classes of panel


On the screenshot, there are classes names that define specified elements.

Table 6.177. Component skin class

Class nameClass description
rich-panelThe class defines a panel common style. It's used in the outside <div> element
rich-panel-headerThe class defines a header style. It's applicable for header elements of all panels
rich-panel-bodyThe class defines a content style inside a panel. It's applicable for elements inside panels

To redefine an appearance of a particular panel, define your own CSS class. Then it's necessary just to define it in one of components class attributes modifying component style properties.

Example:

CSS code piece used on a page:

Example:


...
    .rich-panel-header{
        background-color:#F99;
    }
    .myClass{
        font-style:italic;
    }
...

Hence, a header class is redefined for all panels (its color changed) of this page and body class is extended with the custom style properties (font-style) for this particular panel. As a result, the panel with a header redefined color and a text style in body is got.

Panel with redefined header and body text style

Figure 6.69. Panel with redefined header and body text style


6.55.10. Relevant resources links

Here you can see the example of <rich:panel> usage and sources for the given example.

6.56.  < rich:panelBar >

6.56.1. Description

panelBar is used for grouping any content which is loaded on the client side and appears as groups divided on child panels after the header is clicked.

PanelBar with content inside

Figure 6.70. PanelBar with content inside


6.56.2. Key Features

  • Skinnable slide panel and child items
  • Groups any content inside each panel

Table 6.178. rich : panelBar attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
contentClassThe component content style class
contentStyleThe component content style
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter.
headerClassThe component header style class
headerClassActiveThe component header style class active
headerStyleThe component header style
headerStyleActiveThe component header style active
heightThe height of the slide panel. Might be defined as pixels or as percentage. The default height is 100%
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
onclickJavaScript code for call before header onclick
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used.
selectedPanelAttribure defines name of selected item
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute.
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator.
valueThe initial value to set when rendered for the first time
valueChangeListenerListener for value changes
widthThe width of the slide panel. Might be defined as pixels or as percentage. The default width is 100%

Table 6.179. Component identification parameters

NameValue
component-typeorg.richfaces.PanelBar
component-classorg.richfaces.component.html.HtmlPanelBar
component-familyorg.richfaces.PanelBar
renderer-typeorg.richfaces.PanelBarRenderer
tag-classorg.richfaces.taglib.PanelBarTag

6.56.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:panelBar>
        <!--//... -->
        <rich:panelBarItem label="Canon">
            ...
        </rich:panelBarItem>
        <rich:panelBarItem label="Nikon">
            ...
        </rich:panelBarItem>
    </rich:panelBar>
...

6.56.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlPanelBar;
...
HtmlPanelBar myBar = new HtmlPanelBar();
...

6.56.5. Details of Usage

As it was mentioned above, panelBar is used for grouping any content on the client, thus its customization deals only with specification of sizes and styles for rendering.

"width" and "height" (both are 100% on default) attributes stand apart.

Style attributes are described further.

panelBar could contain any number of child panelBarItem components inside, which content is uploaded onto the client and headers are controls to open the corresponding child element.

6.56.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method.

Default style classes are mapped on skin parameters.

To redefine appearance of all panelBars at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the panelBar to your page style sheets (PanelBar itself has no properties mapped on a skin, it's described for its children).

6.56.7. Definition custom style classes

There is one predefined class for the panelBar, which is applicable to the whole component, specifying padding, borders, and etc.

Custom style class of panelBar

Figure 6.71. Custom style class of panelBar


Table 6.180. Predefined component skin class

Class nameClass description
rich-panelbarapplicable for the whole panelBar (padding, border)

Other classes responsible for elements rendering are described for child panelBarItem elements and could be found in the components chapters.

To change style peculiarities of the particular panelBar and child elements, define your own style classes in the corresponding panelBar attributes.

Table 6.181. Style component classes

A class attributeA component element defined by an attribute
styleClassapplicable to the whole panel together with headers
headerClassapplicable to headers elements
contentClassapplicable to panels

CSS code piece used on a page:

Example:

...
    . rich-panelbar{
        padding:10px;
    }
    .myClass{
        font-style:italic;
    }
...

When using headerClass and headerClassActive attributes the declaration of headerClass should precede the one of headerClassActive:

Example:

...
    .headerClass{
        ...
    }
    .headerClassActive{
        ...
    }
...

The component is defined in the following way:

Example:


...
    <rich:panelBar contentClass="myClass">
        <rich:panelBarItem>
        ...
        </rich:panelBarItem>
    </rich:panelBar>
...

Hence, padding for all panelBars is changed on a page as well as a font for particular panelBarItems content.

6.56.8. Relevant resources links

Here you can see the example of <rich:panelBar> usage and sources for the given example.

6.57.  < rich:panelBarItem >

6.57.1. Description

panelBarItem is used for grouping any content inside within one panelBar which is loaded on client side and appears as groups divided on child panels after header is clicked.

PanelBarItem component

Figure 6.72. PanelBarItem component


6.57.2. Key Features

  • Highly customizable look and feel
  • Groups any content inside each Panels

Table 6.182. rich : panelBarItem attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
contentClassThe component content style class
contentStyleThe component content style
headerClassThe component header style class
headerClassActiveThe component header style class active
headerStyleThe component header style
headerStyleActiveThe component header style active
idEvery component may have a unique id that is automatically created if omitted
labelLabel text appears on a panel item header
nameAttribute defines item name
renderedIf "false", this component is not rendered

Table 6.183. Component identification parameters

NameValue
component-typeorg.richfaces.PanelBarItem
component-classorg.richfaces.component.html.HtmlPanelBarItem
component-familyorg.richfaces.PanelBarItem
renderer-typeorg.richfaces.PanelBarItemRenderer
tag-classorg.richfaces.taglib.PanelBarItemTag

6.57.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:panelBar>
        <rich:panelBarItem label="Canon">
            ...
        </rich:panelBarItem>
        <rich:panelBarItem label="Nikon">
            ...
        </rich:panelBarItem>
    </rich:panelBar>
...

6.57.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlPanelBarItem;
...
HtmlPanelBarItem myBarItem = new HtmlPanelBarItem();
...

6.57.5. Details of Usage

The "label" attribute defines text to be represented. If you can use the "label" facet, you can even not use the "label" attribute.

Example:

...
    <rich:panelBarItem...>
        <f:facet name="label">  
            <h:graphicImage value="/images/img1.gif"/>
        </f:facet>
        ...
        <!--Any Content inside-->
        ...
    </rich:panelBarItem>
...

As it was mentioned above, panelBarItem is used for grouping any content inside within one panelBar, thus its customization deals only with specification of sizes and styles for rendering.

panelBar could contain any number of child panelBarItem components inside, which content is uploaded onto the client and headers are controls to open the corresponding child element.

6.57.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all panelBarItem at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the panelBarItem to your page style sheets

6.57.7. Skin parameters redefinition

Table 6.184. Skin parameters for the panel content appearance

Skin parameters for a hintCSS properties
panelTextColorcolor
generalBackgroundColorbackground-color
bordertableBorderColor

Table 6.185. Parameters for panel header appearance

Skin parametersCSS properties
headerBackgroundColorborder

6.57.8. Definition custom style classes

PanelBarItem style classes

Figure 6.73. PanelBarItem style classes


There are two predefined classes for the panelBarItem shown on the screenshot and described in the table below

Table 6.186. Predefined component skin class

Class nameClass description
rich-panelbar-headerapplicable for panelBarItem headers
rich-panelbar-contentapplicable for panelBarItem

It's necessary to define a class according to the corresponding name, so as an appearance of all panelBarItems on a page is changed at once.

To change style peculiarities of the particular panelBarItems, define your own style classes in the corresponding panelBarItems attributes.

Table 6.187. Style component classes

A class attributeA component element defined by an attribute
headerClassapplicable to header elements
contentClassapplicable to panel elements

Example:

CSS code piece used on a page:

Example:

...
    .rich-panelbar-header{
        font-size:14px;
    }
    .myClass{
        font-style:italic;
    }
...

The component is defined in the following way:

Example:


...
    <rich:panelBar>
        <rich:panelBarItem contentClass="myClass">
            ...
        </rich:panelBarItem>
    </rich:panelBar>
...

Hence, a font size of all panelBarItem headers is changed on a page as well as a font for the particular panelBarItem content.

6.58.  < rich:panelMenu >

6.58.1. Description

The <rich:panelMenu> component is used to define an inline vertical menu on a page.

6.58.2. Key Features

  • Highly customizable look and feel
  • Different submission modes
  • Collapsing/expanding sublevels with optional request sending
  • Custom and predefined icons support
  • Disablement support

Table 6.188. rich : panelMenu attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
disabledIf true sets state of the item to disabled state. false is default.
disabledGroupClassSpace-separated list of CSS style class(es) that are be applied to disabled group of this component
disabledGroupStyleCSS style(s) is/are to be applied to disabled group when this component is rendered
disabledItemClassSpace-separated list of CSS style class(es) that are be applied to disabled item of this component
disabledItemStyleCSS style(s) is/are to be applied to disabled item when this component is rendered.
eventDefines the event on the representation element that triggers the submenu's expand/collapse. (default=onclick)
expandModeSet the submission mode for all panel menu groups after expand/collapse except ones where this attribute redefined. (ajax, server, none(Default))
expandSingleWhether only one panel menu node on top level can be opened at a time. If the value of this attribute is true, the previously opened node on the top level is closed. If the value is false, the node is left opened. The default value is false.
groupClassSpace-separated list of CSS style class(es) that are be applied to group of this component
groupStyleCSS style(s) is/are to be applied to group when this component is rendered
hoveredGroupClassSpace-separated list of CSS style class(es) that are be applied to hovered group of this component
hoveredGroupStyleCSS style(s) is/are to be applied to hovered group when this component is rendered
hoveredItemClassSpace-separated list of CSS style class(es) that are be applied to hovered item of this component
hoveredItemStyleCSS style(s) is/are to be applied to hovered item when this component is rendered
iconCollapsedGroupPath to the icon to be displayed for the collapsed Group state
iconCollapsedTopGroupPath to the icon to be displayed for the collapsed top group state
iconDisabledGroupPath to the icon to be displayed for the disabled group state
iconDisabledItemPath to the icon to be displayed for the disabled item state
iconExpandedGroupPath to the icon to be displayed for the expanded Group state
iconExpandedTopGroupPath to the icon to be displayed for the expanded top group state
iconGroupPositionPosition of the icon (left, right none (default) ) for the group icon
iconGroupTopPositionPosition of the icon (left, right none (default) ) for the top group icon
iconItemPath to the icon to be displayed for the enabled item state
iconItemPositionPosition of the icon (left, right none (default) ) for the item icon
iconItemTopPositionPosition of the icon (left, right none (default) ) for the top item icon
iconTopDisabledItemPath to the icon to be displayed for the disabled top item state
iconTopDisableGroupPath to the icon to be displayed for the disabled top Group state
iconTopItemPath to the icon to be displayed for the enabled top item state
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
itemClassSpace-separated list of CSS style class(es) that are be applied to item of this component
itemStyleCSS style(s) is/are to be applied to item when this component is rendered.
modeSet the submission mode for all panel menu items on the panel menu except ones where this attribute redefined. (ajax, server,(Default), none)
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
ongroupcollapseHTML: script expression; some group was closed
ongroupexpandHTML: script expression; some group was activated
onitemhoverHTML: script expression; some item was hovered
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: script expression; a pointer was moved within.
onmouseoutHTML: script expression; a pointer was moved away.
onmouseoverHTML: script expression; a pointer was moved onto.
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
selectedChildcontain the name or the clientId of any of the item or group, the child defined in this attribute should be highlighted on PanelMenu rendering
styleThe CSS style for the panel menu.
styleClassThe CSS class for the panel menu.
topGroupClassSpace-separated list of CSS style class(es) that are be applied to top group of this component
topGroupStyleCSS style(s) is/are to be applied to top group when this component is rendered
topItemClassSpace-separated list of CSS style class(es) that are be applied to top item of this component
topItemStyleCSS style(s) is/are to be applied to top item when this component is rendered
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe initial value to set when rendered for the first time
valueChangeListenerListener for value changes
widthSet minimal width for the menu.

Table 6.189. Component identification parameters

NameValue
component-typeorg.richfaces.PanelMenu
component-classorg.richfaces.component.html.HtmlPanelMenu
component-familyorg.richfaces.PanelMenu
renderer-typeorg.richfaces.PanelMenuRenderer
tag-classorg.richfaces.taglib.PanelMenuTag

6.58.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

Example:


...
      <rich:panelMenu event="onmouseover">
            <!--Nested panelMenu components-->
      </rich:panelMenu>
...

6.58.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlPanelMenu;  
...
HtmlPanelMenu myPanelMenu = new HtmlPanelMenu();
...

6.58.5. Details of Usage

All attributes are not required.

Use "event" attribute to define an event for appearance of collapsing/expanding sublevels. Default value is "onclick" . An example could be seen below.

Example:


...
      <rich:panelMenu event="onmouseover">
            <!--Nested panelMenu components-->
      </rich:panelMenu>
...

Switching mode could be chosen with the "mode" attribute for all panelMenu items except ones where this attribute was redefined. By default all items send traditional request.

The "expandMode" attribute defines the submission modes for all collapsing/expanding panelMenu groups except ones where this attribute was redefined.

The "mode" and "expandMode" attributes could be used with three possible parameters.

  • Server (default)

The common submission of the form is performed and a page is completely refreshed.

  • Ajax

An Ajax form submission is performed, and additionally specified elements in the "reRender" attribute are reRendered.

  • None

"Action" and "ActionListener" attributes are ignored. Items don't fire any submits itself. Behavior is fully defined by the components nested to items. Groups expand on the client side.

Example:


...
      <rich:panelMenu event="onclick" submitMode="none">
            < rich:panelMenuItem label="Link to external page">
                  <h:outputLink ... >
            <rich:panelMenuItem>
      </rich:panelMenu>
...

Note:

As the <rich:panelMenu> component doesn't provide its own form, use it between <h:form> and </h:form> tags.

The "expandSingle" attribute is defined for expanding more than one submenu on the same level. The default value is "false" . If it's true the previously opened group on the top level closes before opening another one. See the picture below.

Using the "expandSingle" attribute

Figure 6.74. Using the "expandSingle" attribute


The "selectedChild" attribute is used for defining the name of the selected group or item. An example for group is placed below:

Here is an example:

Example:


...
      <rich:panelMenu selectedChild="thisChild">
        <rich:panelMenuGroup label="Group1" name="thisChild">
          <!--Nested panelMenu components-->
        </rich:panelMenuGroup>
      </rich:panelMenu>
...

6.58.6. JavaScript API

In Java Script code for expanding/collapsing group element creation it's necessary to use doExpand()/doCollapse() function.

Table 6.190. JavaScript API

FunctionDescription
doExpand()Expand group element
doCollapse()Collapse group element

6.58.7. Look-and-Feel Customization

As this component is just a wrapper for its children its provide the only "rich-panel-menu" class for wrapper div element. To redefine appearance of particular panel menus, it's possible to define your own CSS class. And then just define it in the components class attribute.

6.58.8. Relevant resources links

Here you can see the example of <rich:panelMenu> usage and sources for the given example.

6.59.  < rich:panelMenuGroup >

6.59.1. Description

The <rich:panelMenuGroup> component is used to define an expandable group of items inside the panel menu or other group.

6.59.2. Key Features

  • Highly customizable look-and-feel
  • Different submission modes inside every group
  • Optional submissions on expand collapse groups
  • Custom and predefined icons supported
  • Support for disabling

Table 6.191. rich : panelMenuGroup attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
alignleft|center|right|justify [CI] Deprecated. This attribute specifies the horizontal alignment of its element with respect to the surrounding context. Possible values: * left: text lines are rendered flush left. * center: text lines are centered. * right: text lines are rendered flush right. * justify: text lines are justified to both margins. The default depends on the base text direction. For left to right text, the default is align=left, while for right to left text, the default is align=right
altFor a user agents that cannot display images, forms, or applets, this attribute specifies alternate text. The language of the alternate text is specified by the lang attribute
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disabledWhen set for a form control, this boolean attribute disables the control for user input
disabledClassClass to be applied to disabled items.
disabledStyleCSS style rules to be applied to disabled items.
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
expandedIf “true” group will be displayed expanded initially.
expandModeSet the submission mode for all panel menu groups after expand/collapse except ones where this attribute redefined. (ajax, server, none(Default))
focusid of element to set focus after request completed on client side
hoverClassClass to be applied to hovered items.
hoverStyleCSS style rules to be applied to hovered items.
iconClassClass to be applied to icon element.
iconCollapsedPath to the icon to be displayed for the collapsed item state
iconDisabledPath to the icon to be displayed for the disabled item state
iconExpandedPath to the icon to be displayed for the expanded item state
iconStyleCSS style rules to be applied
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
labelDisplayed node's text
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
maxlengthWhen the type attribute has the value "text" or "password", this attribute specifies the maximum number of characters the user may enter. This number may exceed the specified size, in which case the user agent should offer a scrolling mechanism. The default value for this attribute is an unlimited number
name'selectedChild' attribute of PanelMenu refers to group/item with the same name
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
oncollapseHTML: script expression; group was closed
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onexpandHTML: script expression; group was opened
onfocusHTML: script expression; the element got the focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; The onselect event occurs when a user selects some text in a text field. This attribute may be used with the INPUT and TEXTAREA elements
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
sizeThis attribute tells the user agent the initial width of the control. The width is given in pixels except when type attribute has the value "text" or "password". In that case, its value refers to the (integer) number of characters
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) to be applied when this component is rendered.
styleClassCorresponds to the HTML class attribute.
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
targetTarget frame for action to execute.
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe initial value to set when rendered for the first time
valueChangeListenerListener for value changes

Table 6.192. Component identification parameters

NameValue
component-typeorg.richfaces.PanelMenuGroup
component-classorg.richfaces.component.html.HtmlPanelMenuGroup
component-familyorg.richfaces.PanelMenuGroup
renderer-typeorg.richfaces.PanelMenuGroupRenderer
tag-classorg.richfaces.taglib.PanelMenuGroupTag

6.59.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

Example:


...
      <rich:panelMenu>
            <rich:panelMenuGroup label="Group1">
                  <!--Nested panelMenu components-->
            </rich:panelMenuGroup>
      </rich:panelMenu>
...

6.59.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlPanelMenuGroup;     
...
HtmlPanelMenuGroup myPanelMenuGroup = new HtmlPanelMenuGroup();
...

6.59.5. Details of Usage

All attributes except "label" are optional. The "label" attribute defines text to be represented.

Switching mode could be chosen with the "expandMode" attribute for the concrete panelMenu group.

The "expandMode" attribute could be used with three possible parameters:

  • Server (default)

The common submission of the form is performed and a page is completely refreshed.

  • Ajax

Ajax form submission is performed, and additionally specified elements in the "reRender" attribute are reRendered.

  • None

"Action" and "ActionListener" attributes are ignored. Items don't fire any submits itself. Behavior is fully defined by the components nested to items.

There are three icon-related attributes. The "iconExpanded" attribute defines an icon for an expanded state. The "iconCollapsed" attribute defines an icon for a collapsed state. The "iconDisabled" attribute defines an icon for a disabled state.

Default icons are shown on the picture below:

Default icons

Figure 6.75. Default icons


Here is an example:

Example:


...
      <rich:panelMenu>
            <rich:panelMenuGroup label="Group1" iconExpanded="disc" iconCollapsed="chevron">
                  <!--Nested panelMenu components-->
            </rich:panelMenuGroup>
      </rich:panelMenu>
...

As the result the pictures are shown below. The first one represents the collapsed state, the second one - expanded state:

Collapsed state

Figure 6.76. Collapsed state


Expanded state

Figure 6.77. Expanded state


It's also possible to define a path to the icon. Simple code is placed below.


...
      <rich:panelMenu>
            <rich:panelMenuGroup label="Group1" iconExpanded="\images\img1.gif" iconCollapsed="\images\img2.gif">
                  <!--Nested menu components-->
            </rich:panelMenuGroup>
      </rich:panelMenu>
...

6.59.6. JavaScript API

In Java Script code for expanding/collapsing group element creation it's necessary to use doExpand()/doCollapse() function.

Table 6.193. JavaScript API

FunctionDescription
doExpand()Expand group element
doCollapse()Collapse group element

6.59.7. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all panel menu groups at once:

  • Redefine the corresponding skin parameters

  • Add to your style sheets style classes used by a panel menu group

6.59.8.  Skin parameters redefinition

Table 6.194. Skin parameters redefinition for table element of the first level group

Parameters for table element of the first level groupCSS properties
headerWeightFontfont-weight
generalFamilyFontfont-family
headerSizeFontfont-size
headerTextColorcolor
headerBackgroundColorbackground-color

Table 6.195. Skin parameters redefinition for table element of the second and next levels groups

Parameters for table element of the second and next levels groupsCSS properties
headerWeightFontfont-weight
headerFamilyFontfont-family
headerSizeFontfont-size
generalTextColorcolor
tableBorderColorborder-top-color

Table 6.196. Skin parameter redefinition for wrapped div element of the first level group

Parameter for wrapped div element of the first level groupCSS properties
panelBorderColorborder-color

6.59.9. Definition of Custom Style Classes

Classes names

Figure 6.78. Classes names


On the screenshot, there are classes names defining specified elements.

Table 6.197. Component skin class

Class nameDescription
rich-pmenu-top-group-divDefines top panel menu group common styleClass. It's used in the outside <div> element
rich-pmenu-top-groupDefines top panel menu group wrapper table element
rich-pmenu-top-group-self-iconDefines top panel menu group icon element
rich-pmenu-top-group-self-labelDefines top panel menu group label element

This classes set is related to upper level of nodes. For all nodes starting with the second level there are similar classes:

  • rich-pmenu-group-div
  • rich-pmenu-group
  • rich-pmenu-group-self-icon
  • rich-pmenu-group-self-label

In order to redefine the style for all panel menu groups on a page using CSS, it's enough to create classes with the same names and define the necessary properties in them.

To change the style of particular panel menu groups define your own style classes in the corresponding panelMenuGroup attributes.

6.60.  < rich:panelMenuItem >

6.60.1. Description

The <rich:panelMenuItem> component is used to define a single item inside popup list.

6.60.2. Key Features

  • Highly customizable look-and-feel
  • Different submission modes
  • Optionally supports any content inside
  • Custom and predefined icons supported
  • Support for disabling

Table 6.198. rich : panelMenuItem attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionactionExpression
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disabledIf “true” sets state of the item to disabled state. “false” is default.
disabledClassClass to be applied to disabled items.
disabledStyleCSS style rules to be applied to disabled items.
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
hoverClassClass to be applied to hovered items.
hoverStyleCSS style rules to be applied to hovered items.
iconPath to the icon or the default one name to be displayed for the enabled item state
iconClassClass to be applied to icon element.
iconDisabledPath to the icon to be displayed for the disabled item state
iconStyleCSS style rules to be applied
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
labelDefines representation text for menuItem.
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
modeSet the submission mode (ajax,server(Default),none)
name'selectedChild' attribute of PanelMenu refers to group/item with the same name
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
targetTarget frame for action to execute.
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component

Table 6.199. Component identification parameters

NameValue
component-typeorg.richfaces.PanelMenuItem
component-classorg.richfaces.component.html.HtmlPanelMenuItem
component-familyorg.richfaces.PanelMenuItem
renderer-typeorg.richfaces.PanelMenuItemRenderer
tag-classorg.richfaces.taglib.PanelMenuItemTag

6.60.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

Example:


...
      <rich:panelMenu>
             ...
            <rich:panelMenuItem value="Item1"/>
            ... 
      </rich:panelMenu>
...

6.60.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlPanelMenuItem;  
...
HtmlPanelMenuItem myPanelMenuItem = new HtmlPanelMenuItem();
...

6.60.5. Details of Usage

All attributes except "label" are optional. The "label" attribute defines text to be represented.

The "mode" attribute could be used with three possible parameters:

  • Server (default)

The common submission of the form is performed and a page is completely refreshed.

  • Ajax

Ajax form submission is performed, and additionally specified elements in the "reRender" attribute are reRendered.

  • None

"Action" and "ActionListener" attributes are ignored. Items don't fire any submits itself. Behavior is fully defined by the components nested to items.

Here is an example for value "none" :

Example:


...
      <rich:panelMenu>
            ...
            <rich:panelMenuItem submitMode="none" onclick="document.location.href='http://labs.jboss.com/jbossrichfaces/">
                  <h:outputLink value="http://labs.jboss.com/jbossrichfaces/">
                        <h:outputText value="RichFaces Home Page"></h:outputText>
                  </h:outputLink>
            </rich:panelMenuItem>
            ...
      </rich:panelMenu>
...

There are two icon-related attributes. The "icon" attribute defines an icon. The "iconDisabled" attribute defines an icon for a disabled item.

Default icons are shown on the picture below:

Default icons

Figure 6.79. Default icons


Here is an example:

Example:


...
      <rich:panelMenu>
            ...
            <rich:panelMenuItem ="Item 1.1" icon="chevronUp" />
            ... 
      </rich:panelMenu>
...

As the result the picture is shown below:

Using an "icon" attribute

Figure 6.80. Using an "icon" attribute


It's also possible to define a path to the icon. Simple code is placed below.


...
      <rich:panelMenu>
            ...
            <rich:panelMenuItem ="Item 1.1" icon="\images\img1.gif" />
            ... 
      </rich:panelMenu>
...

6.60.6. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all panel menu items at once:

  • Redefine the corresponding skin parameters

  • Add to your style sheets style classes used by a panel menu item

6.60.7.  Skin parameters redefinition

Table 6.200. Skin parameters redefinition for a table element item of the first level

Parameters for table element item of first levelCSS properties
generalFamilyFontfont-family
generalWeightFontfont-weight
generalSizeFontfont-size
generalTextColorcolor
panelBorderColorborder-top-color

Table 6.201. General skin parameter redefinition for disabled item

Parameter for disabled itemCSS properties
panelBorderColorcolor

6.60.8. Definition of Custom Style Classes

Classes names

Figure 6.81. Classes names


On the screenshot, there are classes names defining specified elements.

Table 6.202. Component skin class

Class nameDescription
rich-pmenu-itemDefines panel menu item common styleClass
rich-pmenu-item-iconDefines panel menu item icon
rich-pmenu-item-labelDefines panel menu item label element

This classes set is related to the second and all other lower levels of items. For all items starting from the first level there are similar classes:

  • rich-pmenu-top-item
  • rich-pmenu-top-item-icon
  • rich-pmenu-top-item-label

In order to redefine the style for all panel menu items on a page using CSS, it's enough to create classes with the same names and define the necessary properties in them.

To change the style of particular panel menu items define your own style classes in the corresponding panelMenuItem attributes.

6.61.  < rich:scrollableDataTable >

6.61.1. Description

The <rich:scrollableDataTable> component is used for the table-like component creation. The component just adds the set of additional features described below in comparison with the standard table.

ScrollableDataTable component

Figure 6.82. ScrollableDataTable component


6.61.2. Key Features

  • Highly customizable look and feel
  • Variable content of the table cells
  • Dynamically fetching the rows from the server when the table is scrolled up and down
  • Resizing columns by mouse dragging the column bar
  • Sorting column by clicking the header
  • Fixed one or more left columns when table is scrolled horizontally
  • One and multi-selection rows mode
  • Built-it drag-n-drop support

Table 6.203. rich : scrollableDataTable attributes

Attribute NameDescription
activeClassA CSS class to be applied to an active row
ajaxKeysThis attribute defines rows that are updated after an AJAX request
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
captionClassSpace-separated list of CSS style class(es) that are be applied to caption for this component
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
componentStateIt defines EL-binding for a component state for saving or redefinition
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
firstA zero-relative row number of the first row to display
focusid of element to set focus after request completed on client side
footerClassSpace-separated list of CSS style class(es) that are be applied to any footer generated for this table
frozenColCountDefines the number of the fixed columns from the left side that will not be scrolled via horizontal scroll. Default value is '0'
headerClassSpace-separated list of CSS style class(es) that are be applied to any header generated for this table
heightDefines a height of the component. Default value is 500px
hideWhenScrollingIf 'true' data will be hidden during scrolling. Can be used for increase performance. Default value is 'false'
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
onRowClickHTML: a script expression; a pointer button is clicked on row
onRowDblClickHTML: a script expression; a pointer button is double-clicked on row
onRowMouseDownHTML: script expression; a pointer button is pressed down on row
onRowMouseUpHTML: script expression; a pointer button is released on row
onselectionchangeHTML: script expression to invoke on changing of rows selection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyThe attribute is a representation of an identifier for a specific data row
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
scriptVarName of JavaScript variable corresponding to component
selectedClassName of the CSS class for a selected row
selectionValue binding representing selected rows
sortModeDefines mode of sorting. Possible values are 'single' for sorting of one column and 'multi' for some.
sortOrderValueBinding pointing at a property of a class to manage rows sorting
stateVarThe attribute provides access to a component state on the client side
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating
widthDefines a width of the component. Default value is 700px

Table 6.204. Component identification parameters

NameValue
component-typeorg.richfaces.component.ScrollableDataTable
component-classorg.richfaces.component.html.HtmlScrollableDataTable
component-familyorg.richfaces.component.ScrollableDataTable
renderer-typeorg.richfaces.renderkit.html.ScrollableDataTableRenderer
tag-classorg.richfaces.taglib.ScrollableDataTableTag

6.61.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:scrollableDataTable value="#{dataTableScrollerBean.allCars}" var="category">
        <!--...//Set of columns and header/footer facets-->
    </rich:scrollableDataTable>
...

6.61.4. Dynamical creation from Java code

Example:


import org.richfaces.component.html.HtmlScrollableDataTable;
...
HtmlScrollableDataTable myScrollableDataTable = new HtmlScrollableDataTable();
...

6.61.5. Details of Usage

The component represents on a page as a scrollable table with some fixed (non-scrollable) rows (header, footer) and columns. Columns of the table are optionally resizable. Resizing is available using "drag and drop" of the column vertical borders. There is possibility to expand or collapse the columns through JS API on the client side. User can define the number of the fixed columns from the left side using attribute "frozenColCount" that will not be scrolled via horizontal scroll.

There is possibility to increase component performance using attribute "hideWhenScrolling" . If attribute value is 'true' data will be hidden during scrolling.

It's possible to select the whole row with onclick on the row or some set of rows. Selection is optional and availability of such feature is defined on the component. There are two ways to select a few rows:

  • Just clicking the columns one by one.
  • Clicking some row with the SHIFT button hold. In this case all the rows starting from last selected up to clicked should be selected.

The columns provides the possibility of expanding/collapsing on the client side through the next JS API:

  • doCollapse(columnId) - Performs the collapse action for the column with the corresponding id

It's possible to sort the table content after clicks on the header. The feature is optional. Every column should be pointed to the comparator method that will be used for sorting the table. In case the <rich:scrollableDataTable> is already sorted by some column and the header of this column has been clicked again - the sorting will be reversed.

The typical variant of using:


...
<rich:scrollableDataTable value="#{modelBuilder.model}" var="issues"
            frozenColCount="1"
            first="0"
            rows="40" 
            width="300px"
            height="396px">
        
    <rich:column width="100px">
        <f:facet name="header" >
            <h:outputText value="State"/>
        </f:facet>
        <h:outputText value="#{issues.cell1}"/>
        <f:facet name="footer">
            <h:outputText value="State"/>
        </f:facet>
    </rich:column>      
    <!--...//Set of columns and header/footer facets-->
</rich:scrollableDataTable>
...

Finally, the component has the following extra attributes for event processing on the client:

  • onselectionchange
  • oncomplete
  • onRowClick
  • onRowDblClick
  • onRowMouseUp
  • onRowMouseDown

6.61.6. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all <rich:scrollableDataTable> components at once:

  • Redefine the corresponding skin parameters

  • Add to your style sheets style classes used by a <rich:scrollableDataTable> component

6.61.7. Skin parameters redefinition

Table 6.205. Skin parameters for all table

Skin parametersCSS properties
tableBackgroundColorbackground-color
tableBorderColorborder-color
tableBorderWidthborder-width

Table 6.206. Skin parameters for header element

Skin parametersCSS properties
headerBackgroundColorbackground-color
headerTextColorcolor
generalFamilyFontfont-family
generalSizeFontfont-size
tableBorderWidthborder-bottom-width
tableBorderColorborder-bottom-color
tableBorderWidthborder-right-width
tableBorderColorborder-right-color

Table 6.207. Skin parameters for footer element

Skin parametersCSS properties
tableSubfooterBackgroundColorbackground-color
generalFamilyFontfont-family
generalSizeFontfont-size
tableBorderColorborder-right-color
generalFamilyFontfont-family
generalSizeFontfont-size

Table 6.208. Skin parameters for row and cells

Skin parametersCSS properties
generalFamilyFontfont-family
generalSizeFontfont-size
tableBorderColorborder-right-color
tableBorderColorborder-bottom-color

Table 6.209. Skin parameters for selected row and cells

Skin parametersCSS properties
additionalBackgroundColorbackground-color

6.61.8. Definition of Custom Style Classes

Classes names

Figure 6.83. Classes names


On the screenshot, there are classes names defining specified elements.

Table 6.210. Classes names that define component appearance

Class nameDescription
rich-sdtDefines the styles for the component appearance

Table 6.211. Classes names that define footer and header elements

Class nameDescription
rich-sdt-header-cellDefines styles for header cells
rich-sdt-footer-cellDefines styles for footer cells
rich-sdt-hsepDefines styles for header separators

Table 6.212. Classes names that define rows and cells appearance

Class nameDescription
rich-sdt-column-cellDefines styles for column cells
rich-sdt-row-selectedDefines styles for selected row
rich-sdt-row-activeDefines styles for active row

In order to redefine the style for all <rich:scrollableDataTable> components on a page using CSS, it's enough to create classes with the same names and define the necessary properties in them.

To change the style of particular <rich:scrollableDataTable> components define your own style classes in the corresponding <rich:scrollableDataTable> attributes.

6.61.9. Relevant resources links

Here you can see the example of <rich:scrollableDataTable>s usage.

6.62.  < rich:separator >

6.62.1. Description

A horizontal line to use as a separator in a layout. The line type can be customized with the "lineType" parameter.

Separator component

Figure 6.84. Separator component


6.62.2. Key Features

  • Highly customizable look and feel
  • Leveraging layout elements creation

Table 6.213. rich : separator attributes

Attribute NameDescription
alignleft|center|right [CI] This attribute specifies a position of the separator according to the document. Permitted values: * left: The separator is to the left of the document. * center: The separator is to the center of the document. * right: The separator is to the right of the document
bindingThe attribute takes a value-binding expression for a component property of a backing bean
heightThe separator height. Default value is 6 pixels
idEvery component may have a unique id that is automatically created if omitted
lineTypeA line type. The possible values are beveled (default), dotted, dashed, double and solid
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleHTML: An advisory title for this element. Often displayed as a tooltip
widthThe separator width that can be defined in pixels or in percents. The default value is 100%

Table 6.214. Component identification parameters

NameValue
component-typeorg.richfaces.separator
component-classorg.richfaces.component.html.HtmlSeparator
component-familyorg.richfaces.separator
renderer-typeorg.richfaces.SeparatorRenderer
tag-classorg.richfaces.taglib.SeparatorTag

6.62.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:separator/>
...

6.62.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlSeparator;
...
HtmlSeparator mySeparator = new HtmlSeparator();
...

6.62.5. Details of Usage

<rich:separator> is a simple layout component which represents a separator stylized as a skin. Thus, the main attributes that define its style are "style" and "styleClass". In addition there are width and height attributes that should be specified in pixels.

The line type can be customized with the "lineType" parameter. For example, different line types are shown after rendering with the following initial settings lineType="double" and "lineType="solid".

Different line types of separator

Figure 6.85. Different line types of separator


Except style attributes, there are also event definition attributes.

  • onmouseover
  • onclick
  • onmouseout
  • etc.

6.62.6. Look-and-Feel Customization

On the component generation, the framework presents a default rich-separator class in styleClass of a generated component, i.e. in order to redefine appearance of all separators at once, it's necessary to redefine this class in your own CSS (replacing in the result properties defined in a skin with your own).

To define appearance of a particular separators, it's possible to write your own CSS classes and properties in the component style attributes ( "style", "styleClass" ) modifying component property.

6.62.7. Relevant resources links

Here you can see the example of <rich:separator> usage and sources for the given example.

6.63.  < rich:simpleTogglePanel >

6.63.1. Description

A collapsible panel, which content shows/hides after activating a header control.

SimpleTogglePanel component

Figure 6.86. SimpleTogglePanel component


6.63.2. Key Features

  • Highly customizable look and feel
  • Support for any content inside
  • Collapsing expanding content
  • Three modes of collapsing/expanding
    • Server
    • Client
    • Ajax

Table 6.215. rich : simpleTogglePanel attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bodyClassA class that defines a style for a panel content
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
headerClassClass that defines the style for panel header
heightHeight of a simple toggle panel content area might be defined as pixels or in percents. By default height is not defined
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
labelMarker to be rendered on a panel header
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
openedA false value for this attribute makes a panel closed as default
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchTypeFacets switch algorithm: "client", "server"(default), "ajax"
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component
widthWidth of a simple toggle panel might be defined as pixels or in percents. By default width is not defined

Table 6.216. Component identification parameters

NameValue
component-typeorg.richfaces.SimpleTogglePanel
component-classorg.richfaces.component.html.HtmlSimpleTogglePanel
component-familyorg.richfaces.SimpleTogglePanel
renderer-typeorg.richfaces.SimpleTogglePanelRenderer
tag-classorg.richfaces.taglib.SimpleTogglePanelTag

6.63.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:simpleTogglePanel>
        ...
    </rich:simpleTogglePanel>
...

6.63.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlSimpleTogglePanel;
...
HtmlSimpleTogglePanel myPanel = new HtmlSimpleTogglePanel();
...

6.63.5. Details of Usage

The component is a simplified version of toggle panel that initially has a defined layout as a panel with a header playing a role of a mode switching control. On a component header element, it's possible to define a label using an attribute with the same name.

Switching mode could be defined with the "switchType" attribute with three possible parameters.

  • Server (DEFAULT)

    The common submission is performed around simpleTogglePanel and a page is completely rendered on a called panel. Only one at a time panel is uploaded onto the client side.

  • Ajax

    AJAX form submission is performed around the panel, content of the called panel is uploaded on Ajax request and additionally specified elements in the "reRender" attribute are rendered. Only one at a time panel is uploaded on the client side.

  • Client

    All panels are uploaded on the client side. Switching from the active to the hidden panel is performed with client JavaScript.

The component could also have an "expanded" (true/false) attribute responsible for keeping a panel state. It gives an opportunity to manage a simpleTogglePanel state from a model.

  • onmouseover
  • onclick
  • onmouseout
  • etc.
SimpleTogglePanel states

Figure 6.87. SimpleTogglePanel states


6.63.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all simpleTogglePanels at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the simpleTogglePanel to your page style sheets

6.63.7. Skin parameters redefinition

Table 6.217. Skin parameters for the whole simpleTogglePanels

Skin parametersCSS properties
overAllBackgroundbackground-color
tableBorderColorborder-color

Table 6.218. Parameters for a header element

Skin parametersCSS properties
headerBackgroundColorbackground-color
headerSizeFontfont-size
headTextColorcolor
preferableHeaderWeightFontfont-weight
headerFamilyFontfont-family

Table 6.219. Parameters for a body element

Skin parametersCSS properties
overAllBackgroundbackground-color
preferableDataSizeFontfont-size
panelTextColorcolor
preferableDataFamilyFontfont-family

6.63.8. Definition custom style classes

Style classes of simpleTogglePanel

Figure 6.88. Style classes of simpleTogglePanel


On the screenshot, there are specific classes names that define specified elements. Except these two classes, one more class specified for the whole wrapper <div> element. See the table:

Table 6.220. Predefined component skin classes

Class nameClass description
rich-stglpanelThe class defines a simpleTogglePanel common style. It's used in the outside <div> element
rich-stglpanel-headerThe class defines a header style. It's applicable for header elements of all simple toggle panels
rich-stglpanel-bodyThe class defines content style inside a panel. It's applicable for elements inside simple toggle panels

To redefine a style of all simple toggle panels on a page with CSS, create classes with the corresponding names and define the necessary properties in them.

To change style peculiarities of a particular simpleTogglePanels, define your own style classes in the corresponding simpleTogglePanels attributes.

It's necessary to define a class according to the corresponding name, so as an appearance of all simpleTogglePanels on a page is changed at once.

Table 6.221. Style component classes

Class nameClass description
styleClassThe class defines panel common style. It's used in the outside <div> element
bodyClassapplicable to panels body elements
headerClassapplicable to header elements

6.63.9. Relevant resources links

Here you can see the example of <rich:simpleTogglePanel>s usage and sources for the given example.

6.64.  < rich:spacer >

6.64.1. Description

A spacer that is used in layout and rendered as a transparent image.

Spacer component

Figure 6.89. Spacer component


6.64.2. Key Features

  • Easily used as a transparent layout spacer
  • Horizontal or vertical spacing is managed by an attribute
  • Easily customizable sizes parameters

Table 6.222. rich : spacer attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
heightThe height of the spacer defined in pixels. The default value is 1 pixel
idEvery component may have a unique id that is automatically created if omitted
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleHTML: An advisory title for this element. Often used by the user agent as a tooltip
widthThe width of the spacer defined in pixels. The default value is 1 pixel

Table 6.223. Component identification parameters

NameValue
component-typeorg.richfaces.spacer
component-classorg.richfaces.component.html.HtmlSpacer
component-familyorg.richfaces.spacer
renderer-typeorg.richfaces.SpacerRenderer
tag-classorg.richfaces.taglib.SpacerTag

6.64.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:spacer/>
...

6.64.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlSpacer;
...
HtmlSpacer mySpacer = new HtmlSpacer();
...

6.64.5. Details of Usage

<rich:spacer> is a simple layout component which represents a transparent spacer. Thus, the main attributes that define its style are "style" and "styleClass".

In addition, the attributes are responsible for the component size: "width" and "height".

Moreover, to add e.g. some JavaScript effects, events defined on it are used.

  • onmouseover
  • onclick
  • onmouseout
  • etc.

6.64.6. Look-and-Feel Customization

On the component generation, the framework presents a default rich-spacer class in styleClass of a generated component, i.e. in order to redefine appearance of all spacers at once, it's necessary to redefine this class in your own CSS (replacing in the result properties defined in a skin with your own).

To define appearance of the particular spacer, it's possible to write your own CSS classes and properties in the component style attributes ( "style", "styleClass" ) modifying component property.

6.64.7. Relevant resources links

Here you can see the example of <rich:spacer> usage and sources for the given example.

6.65.  < rich:suggestionbox >

Table 6.224. rich : suggestionbox attributes

Attribute NameDescription
ajaxSingleif "true", submit ONLY one field/link, instead of all form controls
bgcolorDeprecated. This attribute sets the background color for the document body or table cells. This attribute sets the background color of the canvas for the document body (the BODY element) or for tables (the TABLE, TR, TH, and TD elements). Additional attributes for specifying text color can be used with the BODY element. This attribute has been deprecated in favor of style sheets for specifying background color information
bindingThe attribute takes a value-binding expression for a component property of a backing bean
borderThis attributes specifies the width (in pixels only) of the frame around a table
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
cellpaddingThis attribute specifies the amount of space between the border of the cell and its contents. If the value of this attribute is a pixel length, all four margins should be this distance from the contents. If the value of the attribute is percentage length, the top and bottom margins should be equally separated from the content based on percentage of the available vertical space, and the left and right margins should be equally separated from the content based on percentage of the available horizontal space
cellspacingThis attribute specifies how much space the user agent should leave between the table and the column on all four sides. The attribute also specifies the amount of space to leave between cells
converterId of Converter to be used or reference to a Converter
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
entryClassName of the CSS class for a suggestion entry element (table row)
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
fetchValueA value to set in the target input element on a choice suggestion that isn't shown in the suggestion table. It can be used for descriptive output comments or suggestions. If not set, all text in the suggestion row is set as a value
firstA zero-relative row number of the first row to display
focusid of element to set focus after request completed on client side
forid (or full path of id's) of target components, for which this element must provide support. If a target component inside of the same <code>NamingContainer</code> (UIForm, UIData in base implementations), can be simple value of the "id" attribute. For other cases must include id's of <code>NamingContainer</code> components, separated by ':'. For search from the root of components, must be started with ':'.
framevoid|above|below|hsides|lhs|rhs|vsides|box|border [CI] This attribute specifies which sides of the frame surrounding a table will be visible. Possible values: * void: No sides. This is the default value. * above: The top side only. * below: The bottom side only. * hsides: The top and bottom sides only. * vsides: The right and left sides only. * lhs: The left-hand side only. * rhs: The right-hand side only. * box: All four sides. * border: All four sides
frequencyDelay (in seconds) before activating the suggestion pop-up
heightHeight of the pop-up window in pixels
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase.
langCode describing the language used in the generated markup for this component
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
minCharsMinimal number of chars in input to activate suggestion pop-up
nothingLabel"nothingLabel" is inserted to popup list if the autocomplete returns empty list. It isn't selectable and list is closed as always after click on it and nothing is put to input.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
onselectJavaScript code for call on select suggestion, after update value of target element
onsubmitJavaScript code for call before submission of ajax event
paramName the HTTP request parameter with the value of input element token. If not set, it be will sent as an input element name. In this case, input will perform validation and update the value
popupClassHTML CSS class attribute of element for pop-up suggestion content
popupStyleHTML CSS style attribute of element for pop-up suggestion content
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rulesThis attribute specifies which rules will appear between cells within a table. The rendering of rules is user agent dependent. Possible values: * none: No rules. This is the default value. * groups: Rules will appear between row groups (see THEAD, TFOOT, and TBODY) and column groups (see COLGROUP and COL) only. * rows: Rules will appear between rows only. * cols: Rules will appear between columns only. * all: Rules will appear between all rows and columns
selectedClassName of the CSS class for a selected suggestion entry element (table row)
selectValueClassName of the CSS class for a selected suggestion entry element (table cell)
selfRenderedIf "true", forces active Ajax region render response directly from stored components tree, bypasses page processing. Can be used for increase performance. Also, must be set to 'true' inside iteration components, such as dataTable.
shadowDepthPop-up shadow depth for suggestion content
shadowOpacityAttribute defines shadow opacity for suggestion content
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
suggestionActionMethod calls an expression to get a collection of suggestion data on request. It must have one parameter with a type of Object with content of input component and must return any type allowed for <h:datatable>
summaryThis attribute provides a summary of the table's purpose and structure for user agents rendering to non-visual media such as speech and Braille
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
titleAdvisory title information about markup elements generated for this component
tokensThe list (or single value) of symbols which can be used for division chosen of suggestion pop-up values in a target element. After input of a symbol from the list suggestion pop-up it is caused again
valueThe initial value to set when rendered for the first time
varA request-scope attribute via which the data object for the current row will be used when iterating
widthWidth of the pop-up window in pixels
zindexAttribute is similar to the standard HTML attribute and can specify window placement relative to the content

6.66.  < rich:tabPanel >

6.66.1. Description

A tab panel displaying tabs for grouping content of the panel.

TabPanel component

Figure 6.90. TabPanel component


6.66.2. Key Features

  • Skinnable tab panel and child items
  • Disabled/enabled tab options
  • Customizable headers
  • Group any content inside a tab
  • Each tab has a unique name for direct access (e.g. for switching between tabs)
  • Switch methods can be easily customized with attribute to:
    • Server
    • Client
    • AJAX
  • Switch methods can be selected for the whole tab panel and for the each tab separately

Table 6.225. rich : tabPanel attributes

Attribute NameDescription
activeTabClassA CSS class to be applied to an active tab
bindingThe attribute takes a value-binding expression for a component property of a backing bean
contentClassA CSS class for content of a tab panel
contentStyleA CSS style is for the content of a tab panel
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
disabledTabClassA CSS class to be applied to a disabled tab
headerAlignmentSets tab headers alignment. It can be "left" or "right". "left" is used by default
headerClassA CSS style is for the header of a tab panel.
headerSpacingSets tab headers spacing. It should be a valid size unit expression
heightHeight of a tab panel defined in pixels or in percents
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inactiveTabClassCSS class to be applied to an inactive (but not disabled) tab
langCode describing the language used in the generated markup for this component
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
selectedTabAttribute defines name of selected tab
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchTypeTab switch algorithm: "client", "server"(default), "ajax"
tabClassA CSS class to be applied to all tabs
titleAdvisory title information about markup elements generated for this component
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe initial value to set when rendered for the first time
valueChangeListenerListener for value changes
widthWidth of a tab panel defined in pixels or in percents. The default value is 100%

Table 6.226. Component identification parameters

NameValue
component-typeorg.richfaces.TabPanel
component-classorg.richfaces.component.html.HtmlTabPanel
component-familyorg.richfaces.TabPanel
renderer-typeorg.richfaces.TabPanelRenderer
tag-classorg.richfaces.taglib.TabPanelTag

6.66.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:tabPanel>
        <!--//Set of Tabs inside-->
        <rich:tab>
            ...
        </rich:tab>
    </rich:tabPanel>
...

6.66.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlTabPanel;
... 
HtmlTabPanel myTabPanel = new HtmlTabPanel();
...

6.66.5. Details of Usage

As it was mentioned above, TabPanel groups content on panels and performs switching from one to another. Hence, modes of switching between panels are described first of all.

Note:

All tabPanels should be wrapped into a form element so as content is correctly submitted inside. If a form is placed into each tab, the Action elements of Tab controls appear to be out of the form and content submission inside the panels could be performed only for Action components inside tabs.

Switching mode could be chosen with the tabPanel attribute "mode" with three possible parameters.

  • Server (DEFAULT)

    The common submission is performed around tabPanel and a page is completely rendered on a called panel. Only one at a time tabPanel is uploaded onto the client side.

  • Ajax

    AJAX form submission is performed around the tabPanel, content of the called tabPanel is uploaded on Ajax request and additionally specified elements in the "reRender" attribute are rendered. Only one at a time tabPanel is uploaded on the client.

  • Client

    All tabPanels are uploaded on the client side. The switching from the active to the hidden panel is performed with client JavaScript.

As a result, the tabPanel is switched to the second tab according to the action returning outcome for moving onto another page and switching from the second to the first tab is performed.

There is also the "selectedTab" attribute. The attribute keeps an active tab name; therefore, an active tabPanel could be changed with setting a name of the necessary tab to this attribute.

There is also the "headerAlignment" attribute responsible for rendering of tabPanel components. The attribute has several values: left (Default), right, center, which specify Tabs components location on the top of the tabPanel.

Example:


...
    <rich:tabPanel width="40%" headerAlignment="right">
        <rich:tab label="Canon">
            ...
        </rich:tab>
        <rich:tab label="Nikon">
            ...
        </rich:tab>
        <rich:tab label="Olympus">
            ...
        </rich:tab>
    </rich:tabPanel>
...
TabPanel with right aligned tabs

Figure 6.91. TabPanel with right aligned tabs


Except the specific attributes, the component has all necessary attributes for JavaScript events definition.

  • onmouseover
  • onmouseout
  • etc.

6.66.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all tabPanels at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the tabPanel to your page style sheets

6.66.7. Definition custom style classes

TabPanel style classes

Figure 6.92. TabPanel style classes


On the screenshot, there are names on the redefined CSS classes that substituted automatically by the framework in order to define an appearance of the corresponding elements of all tab panels on a page.

Table 6.227. Classes names that define appearance

Class nameDescription
rich-tabpanel-contentTab internal content
rich-tabpanel-content-positionA class for wrapping element content. It should define a shift equal to borders width in order to overlap a panel and tabs
rich-tabhdr-side-borderA class for side elements of a tab header
rich-tabhdr-side-cellA class for a header internal element

Table 6.228. Classes names that define different tab header states (corresponds to rich-tabhdr-side-cell)

Class nameDescription
rich-tabhdr-cell-activeA class for an internal element of an active header
rich-tabhdr-cell-inactiveA class for internal element of an inactive label
rich-tabhdr-cell-disabledA class for an internal element of a disabled label

Also it is possible to change look-and-feel settings of individual tab panel component by writing your own style classes in corresponding class attributes of tabPanel.

6.66.8. Relevant resources links

Here you can see the example of <rich:tabPanel> usage and sources for the given example.

6.67.  < rich:tab >

6.67.1. Description

A tab section within a tab panel.

Tab component

Figure 6.93. Tab component


6.67.2. Key Features

  • Fully skinnable tabs content
  • Disabled/enabled tab options
  • Groups any content inside a tab
  • Each tab has a unique name for a direct access (e.g. for switching between tabs)
  • Switch methods can be easily customized for every tab separately with attribute to:
    • Server
    • Client
    • AJAX

Table 6.229. rich : tab attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disabledDisables a tab in a tab panel
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
labelText for the actual "tab" in a tab section
labelWidthLength for the actual "tab" in a tab section defined in pixels. If it is not defined, the length is calculated basing on a tab label text length
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
nameAttribute defines tab name
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
ontabenterEvent must occurs on the tab which has been entered
ontableaveEvent must occurs on the tab which has been left
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchTypeTab switch algorithm: "client", "server", "ajax", "page"
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
titleHTML: An advisory title for this element. Often displayed as a tooltip

Table 6.230. Component identification parameters

NameValue
component-typeorg.richfaces.Tab
component-classorg.richfaces.component.html.HtmlTab
component-familyorg.richfaces.Tab
renderer-typeorg.richfaces.TabRenderer
tag-classorg.richfaces.taglib.TabTag

6.67.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:tabPanel>
        <!--Set of Tabs inside-->
            <rich:tab>
                ...
            </rich:tab>
    </rich:tabPanel>
...

6.67.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlTab;
... 
HtmlTab myTab = new HtmlTab();
...

6.67.5. Details of Usage

The main component function is to define a content group that is rendered and processed when the tab is active, i.e. click on a tab causes switching onto a tab containing content corresponded to this tab.

The "label" attribute defines text to be represented. If you can use the "label" facet, you can even not use the "label" attribute.

Example:

...
    <rich:tab>
        <f:facet name="label">  
            <h:graphicImage value="/images/img1.gif"/>
        </f:facet>
        ...
        <!--Any Content inside-->
        ...
    </rich:tab>
...

A marker on a tab header defined with the "label" attribute. Moreover, each tab could be disabled (switching on this tab is impossible) with the "disable" attribute.

Example:


...
    <rich:tabPanel width="20%"> 
        <rich:tab label="Tab">
            <h:outputText value="Active Tab content"/>
        </rich:tab>
        <rich:tab label="Disabled Tab" disabled="true">
            ...
        </rich:tab>
        <rich:tab label="Next Enabled Tab">
            ...
        </rich:tab>
    </rich:tabPanel>
...

With this example it's possible to generate the tab panel with the second disabled and two active tabs (see the picture).

Tab Panel with disabled tab

Figure 6.94. Tab Panel with disabled tab


Switching mode could be defined not only for the whole panel tab, but also for each particular tab, i.e. switching onto one tab could be performed right on the client with the corresponding JavaScript and onto another tab with an Ajax request on the server. Tab switching modes are the same as tabPanel ones.

Each tab also has an attribute name (alias for "id" attribute). Using this attribute value it's possible e.g. to set an active tab on a model level specifying this name in the corresponding attribute of the whole tab.

Except the specific component attributes it has all necessary attributes for JavaScript event definition.

  • onmouseover
  • onmouseout
  • etc.

Some event could be performed on the tab which has been entered/left using "ontabenter"/"ontableave" attributes. See the example below.

Example:


...
    <rich:tabPanel>
        <rich:tab label="Tab1" ontabenter="alert()">
            ...
        </rich:tab>
        ...
    </rich:tabPanel>
...

The following example shows how on the client side to get the names of entered/left tabs.


ontabenter="alert(leftTabName)"

6.67.6. Look-and-Feel Customization

For skinnability implementation the components use style class redefinition method. Default style classes are mapped on skin parameters.

Note:

A panel appearance and content is defined with a tab panel i.e. on the tab level it's possible to define only an appearance of this tab header.

To redefine appearance of all tabs at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the tab to your page style sheets

6.67.7. Definition Custom Style Classes

The style peculiarities of a particular Tab variant could be changed with specification of your own StyleClasses attributes.

It's necessary to define a class according to the corresponding name, so as an appearance of all slider on a page is changed at once.

6.68.  < rich:togglePanel >

6.68.1. Description

A wrapper component with named facets, where every facet is shown after activation of the corresponding toggleControl (the other is hidden).

TogglePanel component

Figure 6.95. TogglePanel component


6.68.2. Key Features

  • Support for any content inside
  • Three modes of facets switching
    • Server
    • Client
    • Ajax
  • Controls for togglePanel can be everywhere in layout

Table 6.231. rich : togglePanel attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
initialStateIt contains a name of the first active facet
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
stateOrderNames of the facets in the switching order. If ToggleControl doesn't contain information about a next facet to be shown it is switched corresponding to this attribute
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchTypeFacets switch algorithm: "client", "server"(default), "ajax".
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe initial value to set when rendered for the first time
valueChangeListenerListener for value changes

Table 6.232. Component identification parameters

NameValue
component-typeorg.richfaces.TogglePanel
component-classorg.richfaces.component.html.HtmlTogglePanel
component-familyorg.richfaces.TogglePanel
renderer-typeorg.richfaces.TogglePanelRenderer
tag-classorg.richfaces.taglib.TogglePanelTag

6.68.3. Creating the Component with a Page Tag

Here is a simple example as it could be used in a page:

Example:


...
    <rich:togglePanel>
        <f:facet name="first">
            ...
        </f:facet>
        <f:facet name="second">
            ...
        </f:facet>
            ...
    </rich:togglePanel>
    ...
    <!--//Set of the toggleControls somewhere on a page.-->
...

6.68.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlTogglePanel;
... 
HtmlTogglePanel myPanel = new HtmlTogglePanel();
...

6.68.5. Details of Usage

As it was mentioned above, togglePanel splits content into named facets that become rendered and processed when a click performed on controls linked to this togglePanel (either switched on the client or send requests on the server for switching).

The initial component state is defined with "initialState" attribute, where a facet name that is shown at first is defined.

Note:

It's also possible to define an "empty" facet to implement the functionality as drop-down panels have and make the facet active when no content is required to be rendered.

Switching mode could be defined with the "switchType" attribute with three possible parameters:

  • Server (DEFAULT)

    The common submission is performed around togglePanel and a page is completely rendered on a called panel. Only one at a time the panel is uploaded onto the client side.

  • Ajax

    AJAX form submission is performed around the panel, content of the called panel is uploaded on an Ajax request and additionally specified elements in the "reRender" attribute are rendered. Only one at a time the panel is uploaded on the client side.

  • Client

    All panels are uploaded on the client side. The switching from the active to the hidden panel is performed with client JavaScript.

"Facets" switching order could be defined on the side of <rich:toggleControl> component or on the panel. On the side of the togglePanel it's possible to define facets switching order with the "stateOrder" attribute. The facets names are enumerated in such an order that they are rendered when a control is clicked, as it's not defined where to switch beforehand.

Example:


...
    <rich:togglePanel id="panel" initialState="panelB" switchType="client"
                        stateOrder="panelA,panelB,panelC">
        <f:facet name="panelA">
            ...
        </f:facet>
        <f:facet name="panelB">
            ...
        </f:facet>
        <f:facet name="panelC">
            ...
        </f:facet>
    </rich:togglePanel> 
    <rich:toggleControl for="panel" value="Switch"/>
...

The example shows a togglePanel initial state when the second facet (panelB) is rendered and successive switching from the first to the second happens.

6.68.6. Look-and-Feel Customization

The component doesn't have its own representation rendering only content of its facets, thus all look and feel is set only for content.

6.68.7. Relevant resources links

Here you can see the example of <rich:togglePanel> usage and sources for the given example.

6.69.  < rich:toggleControl >

6.69.1. Description

A link type control for switching between togglePanel facets. Target Panel is specified with "for" attribute. It can be located inside or outside the togglePanel. As the result of switching between facets previous facet is hidden and another one (specified with "switchToState" or panel "stateOrder" attributes) is shown.

ToggleControl component

Figure 6.96. ToggleControl component


6.69.2. Key Features

  • Highly customizable look and feel
  • Can be located anywhere in a page layout
  • Switching is provided in the three modes
    • Server
    • Client
    • Ajax

Table 6.233. rich : toggleControl attributes

Attribute NameDescription
accesskeyAccess key that, when pressed, transfers focus to this element
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionExpressionThe action method binding expression
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submit ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase skip updates of model beans an force render response. Can be used for validate components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move, etc.)
focusid of element to set focus after request completed on client side
forString containing comma separated ids (in the format of a UIComponent.findComponent() call) of the target components.
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
langCode describing the language used in the generated markup for this component
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. if "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onblurJavaScript code executed when this element loses focus
onclickJavaScript code executed when a pointer button is clicked over this element
oncompleteJavaScript code for call after request completed on client side
ondblclickJavaScript code executed when a pointer button is double clicked over this element
onfocusJavaScript code executed when this element receives focus
onkeydownJavaScript code executed when a key is pressed down over this element
onkeypressJavaScript code executed when a key is pressed and released over this element
onkeyupJavaScript code executed when a key is released over this element
onmousedownJavaScript code executed when a pointer button is pressed down over this element
onmousemoveJavaScript code executed when a pointer button is moved within this element
onmouseoutJavaScript code executed when a pointer button is moved away from this element
onmouseoverJavaScript code executed when a pointer button is moved onto this element
onmouseupJavaScript code executed when a pointer button is released over this element
panelIdAttribute defines Id for corresponding panel
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) to be applied when this component is rendered
styleClassSpace-separated list of CSS style class(es) to be applied when this element is rendered. This value must be passed through as the "class" attribute on generated markup
switchToStateContains one of the facets names where target togglePanel is switched to
tabindexPosition of this element in the tabbing order for the current document. This value must be an integer between 0 and 32767
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
titleAdvisory title information about markup elements generated for this component
valueInitial value to set when rendered for the first time

Table 6.234. Component identification parameters

NameValue
component-typeorg.richfaces.ToggleControl
component-classorg.richfaces.component.html.HtmlToggleControl
component-familyorg.richfaces.ToggleControl
renderer-typeorg.richfaces.ToggleControlRenderer
tag-classorg.richfaces.taglib.ToggleControlTag

6.69.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:toggleControl for="panel"/>
        ...
        <rich:togglePanel id="panel" stateOrder="[facets order to be switched]">
            <!--//Set of Facets-->
        </rich:togglePanel>
...

6.69.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlToggleControl;
...
HtmlToggleControl myControl = new HtmlToggleControl();
...

6.69.5. Details of Usage

As it was mentioned above, the control could be in any place in layout and linked to a switching panel that is managed with "for" attribute (in the "for" attribute the full component "id" is specified according to naming containers).

The togglePanel could be also switched from the side of the control instead of being strictly defined in "switchOrder" attribute of <rich:togglePanel>.

Example:


...
    <rich:togglePanel id="panel" initialState="empty" switchType="client">
        <f:facet name="first">
            <h:panelGroup>
                <rich:toggleControl for="helloForm:panel" value="Empty " switchToState="empty"/>
                <rich:toggleControl for="helloForm:panel" value=" Second" switchToState="second"/>
                ...//Some Content
            </h:panelGroup>
        </f:facet>
    <f:facet name="second">
            <h:panelGroup>
                <rich:toggleControl for="helloForm:panel" value="Empty " switchToState="empty"/>
                <rich:toggleControl for="helloForm:panel" value=" first" switchToState="first"/>
                ...//Some Content
            </h:panelGroup>
        </f:facet>
        <f:facet name="empty">
            <h:panelGroup>
                <rich:toggleControl for="helloForm:panel" value="first " switchToState="first"/>
                <rich:toggleControl for="helloForm:panel" value=" second" switchToState="second"/>
            </h:panelGroup>
        </f:facet>
    </rich:togglePanel>
...

In this example the switching is performed on facets specified in the "switchToState" attribute.

6.69.6. Look-and-Feel Customization

On component generation the framework substitutes the default class rich-toggle-control into styleClass of a generated component, i.e. to redefine at once all toggle controls appearance on a page, redefine this class in your CSS.

To define a particular toggle controls appearance, write down your own CSS properties and classes in component style attributes ( "style", "styleClass" )and the properties have been changed.

6.70.  < rich:toolBar >

6.70.1. Description

A horizontal bar with Action items on it that accepts any JSF components as children.

Toolbar with action items

Figure 6.97. Toolbar with action items


6.70.2. Key Features

  • Skinnable menu panel and child items
  • Standard top menu bar that can be used in accordance with a menu component
  • Grouping bar content
  • Easily place content on any side of a menu bar using predefined group layout
  • Predefined separators for menu items and groups
  • Any content inside

Table 6.235. rich : toolBar attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
contentClassA CSS style is to be applied to each element of tool bar content. Use this style, for example, to setup parameters of the font.
contentStyleA CSS style is to be applied to each element of tool bar content.
heightA height of a bar in pixels. If a height is not defined, a bar height depends of the "headerFontSize" skin parameter.
idEvery component may have a unique id that is automatically created if omitted
itemSeparatorA separator between items on a bar. Possible values are none, line, square, disc and grid.
renderedIf "false", this component is not rendered
separatorClassA CSS class to be applied to tool bar separators.
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
widthA width of a bar that can be defined in pixels or as percentage. The default value is 100%.

Table 6.236. Component identification parameters

NameValue
component-typeorg.richfaces.ToolBar
component-classorg.richfaces.component.html.HtmlToolBar
component-familyorg.richfaces.ToolBar
renderer-typeorg.richfaces.ToolBarRenderer
tag-classorg.richfaces.taglib.ToolBarTag

6.70.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:toolBar>
        <!--//...Set of action or other JSF components-->
    </rich:toolBar>
...

6.70.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlToolBar;
...
HtmlToolBar myToolBar = new HtmlToolBar();
...

6.70.5. Details of Usage

A toolBar is a wrapper component that facilitates creation of menu and tool bars. All components defined inside are located on a stylized bar with possibility to group, arrange on the both bar sides, and place predefined separators between them.

Grouping and an input side definition is described for toolBarGroup that defines this functionality.

Separators are located between components with the help of the "itemSeparator" attribute with four predefined values:

  • none
  • line
  • square
  • disc

For example, when setting a separator of a disc type, the following result is produced:

Toolbar with a "disc" separator

Figure 6.98. Toolbar with a "disc" separator


Moreover, for toolBar style "width" and "height" attributes are placed above all.

6.70.6. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all toolBars at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the toolBar to your page style sheets

Table 6.237. Skin parameters redefinition

Skin parameters for the toolbar componentCorresponding CSS parameters
tableBorderColorborder-color
headerBackgroundColorbackground-color

6.70.7. Definition custom style classes

On generating, the component substitutes the default class rich-toolbar-exterior into style class of a generated component, i.e. to redefine at once all toolBars appearance on a page, redefine this class in your CSS.

The component also has the standard attributes "style" and "styleClass" that could redefine an appearance of a particular component variants.

6.70.8. Relevant resources links

Here you can see the example of <rich:toolBar> usage and sources for the given example.

6.71.  < rich:toolBarGroup >

6.71.1. Description

A group of items inside a tool bar.

ToolbarGroup with items on it

Figure 6.99. ToolbarGroup with items on it


6.71.2. Key Features

  • Fully skinnable with its child items
  • Grouping bar content
  • Easily place content on either side of tool bar using a predefined group layout
  • Predefined separators for menu items and groups
  • Any content inside

Table 6.238. rich : toolBarGroup attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
itemSeparator"A separator for the items in a group. Possible values are "none", "line", "square", "disc" and "grid"."
location"A location of a group on a tool bar. Possible values are "left" and "right"."
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
separatorClass"A CSS class to be applied to tool bar group separators."
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute

Table 6.239. Component identification parameters

NameValue
component-typeorg.richfaces.ToolBarGroup
component-classorg.richfaces.component.html.HtmlToolBarGroup
component-familyorg.richfaces.ToolBarGroup
renderer-typeorg.richfaces.ToolBarGroupRenderer
tag-classorg.richfaces.taglib.ToolBarGroupTag

6.71.4. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:toolBar>
        ...
        <rich:toolBarGroup>
            <!--...Set of action or other JSF components-->
        </rich:toolBarGroup>
        <rich:toolBarGroup>
            <!--...Set of action or other JSF components-->
        </rich:toolBarGroup>
        ...
    </rich:toolBar>
...

6.71.5. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlToolBarGroup;
...
HtmlToolBarGroup myToolBarGroup = new HtmlToolBarGroup();
...

6.71.6. Details of Usage

A toolBarGroup is a wrapper component that groups toolBar content and facilitates creation of menu and tool bars. All components defined inside are located on a stylized bar with a possibility to group, arrange on the both bar sides, and place predefined separators between them.

Separators are located between components with the help of the "itemSeparator" attribute with four predefined values:

  • none
  • line
  • square
  • disc

To control the group location inside, use the "location" attribute with left (DEFAULT) and right values.

Example:


...
    <rich:toolBar itemSeparator="disc" width="500">
        <rich:toolBarGroup itemSeparator="line">
            <h:commandLink value="Command 1.1"/>
            <h:commandLink value="Command 2.1"/>
        </rich:toolBarGroup>
        <rich:toolBarGroup itemSeparator="line" location="right">
            <h:commandLink value="Command 1.2"/>
            <h:commandLink value="Command 2.2"/>
        </rich:toolBarGroup>
    </rich:toolBar>
...

The code result is the following:

Stylized toolBarGroup

Figure 6.100. Stylized toolBarGroup


6.71.7. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all toolBarGroups at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the toolBarGroup to your page style sheets

Table 6.240. Skin parameters redefinition

Skin parameters for the toolBarGroup componentCorresponding CSS parameters
headerSizeFontfont-size
headTextColorcolor
headerFamilyFontfont-family

6.71.8. Definition custom style classes

On generating, the component substitutes the default class rich-toolbar-interior into style class of a generated component, i.e. to redefine at once all toolBarGroups appearance on a page, redefine this class in your CSS.

The component also has the standard attribute "style" and "style class" that could redefine an appearance of particular component variants.

It's necessary to define a class according to the corresponding name, so as an appearance of all toolBarGroups on a page is changed at once.

6.72.  < rich:toolTip >

Table 6.241. rich : toolTip attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
delayDelay in milliseconds before tooltip will be displayed.
directionDefines direction of the popup list to appear (top-right, top-left bottom-right, bottom-left, auto(default))
disabledIf false the components is rendered on the client but Js for calling – disabled.
eventevent that triggers the tooltip appearance (default = onmouseover)
followMouseIf 'true' tooltip should follow the mouse while it moves over the parent element
horizontalOffsetSets the horizontal offset between popup list and mouse pointer
idEvery component may have a unique id that is automatically created if omitted
layoutAllowed values: "inline" or "block". Block/inline mode flag. Tooltip will contain div/span elements accordingly.
modecontrols the way of data loading to tooltip and should have following values “client” (default), “ajax”
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after the tooltip shown
ondblclickHTML: a script expression; a pointer button is double-clicked
onhideJavaScript code for call after the tooltip hidden
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onshowJavaScript code for call after the tooltip called (some element overed) but before its requesting
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
valueLabel on the tooltip
verticalOffsetSets the vertical offset between popup list and mouse pointer
zorderThe same as CSS z-index for toolTip.

6.73.  < rich:tree >

6.73.1. Description

A component for a tree-like presentation of data. It includes built-in drag and drop support for its child elements.

Expanded tree with child elements

Figure 6.101. Expanded tree with child elements


6.73.2. Key Features

  • Highly customizable look-and-feel

  • Built-in drag and drop support

  • Built-in Ajax processing

  • Support of template sets for different node types

  • Support of several root elements in a tree

Table 6.242. rich : tree attributes

Attribute NameDescription
acceptedTypesList of drag types to be processed by the current drop zone
adviseNodeOpenedMethodBinding pointing at a method accepting an org.richfaces.component.UITree with return of java.lang.Boolean type. If returned value is: java.lang.Boolean. TRUE, a particular treeNode is expanded; java.lang.Boolean.FALSE, a particular treeNode is collapsed; null, a particular treeNode saves the current state
adviseNodeSelectedMethodBinding pointing at a method accepting an org.richfaces.component.UITree with return of java.lang.Boolean type. If returned value is: java.lang.Boolean. TRUE, a particular treeNode is selected; java.lang.Boolean.FALSE, a particular treeNode is unselected; null, a particular treeNode saves the current state
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
ajaxSubmitSelectionIf "true", an Ajax request to be submit when selecting node
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
changeExpandListenerListener called on expand/collapse event on the node
componentStateIt defines EL-binding for a component state for saving or redefinition
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
dragIndicatorAn indicator component id
dragListenerMethodBinding representing an action listener method that will be notified after drag operation
dragTypeKey of a drag object. It's used to define a necessity of processing the current dragged element on the drop zone side
dragValueData to be sent to the drop zone after a drop event
dropListenerMethodBinding representing an action listener method that will be notified after drop operation
dropValueData to be processed after a drop event
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
highlightedClassCorresponds to the HTML class attribute. Applied to highlighted node
iconThe icon for node
iconCollapsedThe icon for collapsed node
iconExpandedThe icon for expanded node
iconLeafAn icon for component leaves
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateA flag indicating that this component value must be converted and validated immediately (during an Apply Request Values phase), rather than waiting until a Process Validations phase
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
nodeFaceNode face facet name
nodeSelectListenerMethodBinding representing an action listener method that will be notified after selection of node.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncollapseHTML: script expression to invoke on node collapsing
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
ondragendA JavaScript event handler called after a drag operation
ondragenterA JavaScript event handler called on enter draggable object to zone
ondragexitA JavaScript event handler called after a drag object leaves zone
ondragstartA JavaScript event handler called before drag object
ondropIt's an event that is called when something is dropped on a drop zone
ondropendA JavaScript handler for event fired on a drop even the drop for a given type is not available
onexpandHTML: script expression to invoke on node expansion
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectedHTML: script expression to invoke on node selection
preserveDataInRequestIf "true", data is preserved in a request
preserveModelIt can be "state", "request", "none". The default is "request"
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rowKeyVarThe attribute provides access to a row key in a Request scope
selectedClassCorresponds to the HTML class attribute. Applied to selected node
showConnectingLinesIf "true", connecting lines are show
stateAdvisorValueBinding pointing at instance of class implementing org.richfaces.component.state.TreeStateAdvisor interface.
stateVarThe attribute provides access to a component state on the client side
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchTypeTree switch algorithm: "client", "server", "ajax"
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
toggleOnClickIf "false" do not toggle node state on click. If "true", than node will be toggles on click on ether node content, or node icon. Default value is false.
typeMappingMap between a draggable type and an indicator name on zone. it's defined with the pair (drag type:indicator name))
valueThe current value for this component
varAttribute contains a name providing an access to data defined with value

Table 6.243. Component identification parameters

NameValue
component-typeorg.richfaces.Tree
component-classorg.richfaces.component.html.HtmlTree
component-familyorg.richfaces.Tree
renderer-typeorg.richfaces.TreeRenderer
tag-classorg.richfaces.taglib.TreeTag

6.73.3. Creating the Component with a Page Tag

Here is a simple example as it could be used in a page:

Example:


...
    <rich:tree>
        <!--Set of the Tree nodes-->
    </rich:tree>
...

6.73.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlTree;
...
HtmlTree myPanel = new HtmlTree();
...

6.73.5. Details of Usage

As it has been mentioned above the tree component allows to render any tree-like structure of data.

A bean property is passed into a tree "value" attribute. The property keeps the structure of a org.richfaces.component.TreeNode type (you could have a look at this interface description in the API document). The default classes for lists building of a TreeNodeImpl type (it implements a TreeNode interface) for an XML structure XmlNodeData and XmlTreeDataBuilder are implemented in the tree component. Hence, in order to provide your own class for TreeNode, it's necessary only to implement this interface, i.e. the "var" attribute contains a name providing an access to data defined with a value.

For data output, named tree nodes elements are used. Each element, for example depending on its definition, could be rendered with markup defined in one of tree nodes. It's defined with the "nodeFace" attribute that contains treeNode name for elements rendering. It's not necessary to define "nodeFace" attribute. In case when "nodeFace" is undefined the first node inside the tree will be use by default (attributes "rendered and "type" for this node should not be defined).

Example:


nodeFace="#{data.name != 'param-value' ? 'input' : 'text'}"
    

On the screenshot there are examples of nodes defined with different templates on the following conditions.

Different nodes of tree

Figure 6.102. Different nodes of tree


Switching on nodes opening/closing (expanded/collapsed) could be implemented in three modes. It could be specified in the "switchType" attribute.

  • AJAX - request onto the server is used for switching
  • Server - custom requests onto the server are used for switching
  • Client - all data is uploaded onto the server, the switching is implemented with a client script

Common selecting allows also to activate Ajax requests with the "ajaxSubmitSelection" attribute (true/false).

To set a model saving during requests, use the "preserveModel" attribute with state, request (default) and none values. The attribute is used for cashing data between requests in a state or request. The "treeDataLocator" attribute defines a class providing an access to cashed data according to the ids saved in state/request on recovery or cashing data saving the Id on caching.

The "icon" , "iconCollapsed" , "iconExpanded" , "iconLeaf" attributes define icons for the component. Also you can define icons using facets with the same names. If the facets are defined, the corresponding attributes are ignored and facets contents are used as icons. The width of a rendered facet area is 16px.


...
    <rich:tree ....>
        ...
        <f:facet name="icon">
            <hutputText value="A"/>
        </f:facet>
        <f:facet name="iconCollapsed">
            <hutputText value="B"/>
        </f:facet>      
        <f:facet name="iconExpanded">
            <hutputText value="C"/>
        </f:facet>
        <f:facet name="iconLeaf">
            <hutputText value="D"/>
        </f:facet>
        ...
    </rich:tree>
...

6.73.6. Built-In Drag and Drop

The tree component functionality provides a built-in support for Drag and Drop operations. The main usage principles are the same as for Rich Faces Drag and Drop wrapper components. Hence, to get additional information on the topic, read the corresponding chapters:"rich:dndParam" "rich:dragSupport" "rich:dragIndicator" "rich:dropSupport" Tree nodes could be drag or drop elements, so tree has both attributes groups.

Table 6.244. Drag attributes description

dragValueElement value drag passing into processing after a Drop event.
dragIndicatorAn indicator component id.
dragTypeA drag zone name used to define whether processing is necessary with a Drop zone or not.

Table 6.245. Drop attributes description

dropValueElement value drop passed into processing after Drop events .
dropListenerA listener that processes a drop event.
acceptedTypesDrag zone names allowed to be processed with a drop zone.
typeMappingDrag zones names mapping on the corresponding drop zone parameters.

6.73.7. Events handling

Listeners classes that process events on server side are defined with the help:

  • nodeSelectListener is called during request sending on a node selecting event (if request sending on this event is defined)
  • dropListener processes Drop event
  • changeExpandListener processes expand/collapse event of a tree node

Moreover, to add e.g. some JavaScript effects, client events defined on it are used:

  • onexpand - expands a node event
  • oncollapse - collapses a node event
  • ondragexit - element passing out from a tree zone event
  • ondragstart - drags a start event
  • ondragend - drags an end event (a drop event)
  • ondragenter - drags an element appearing on a tree event

Also standart HTML event attributes like "onclick", "onmousedown", "onmouseover" and etc. could be used. Event handlers of a tree component capture events occured on any tree part. But event handlers of treeNode capture events occured on treeNode only, except for children events.

6.73.8. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine an appearance of all trees at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the tree to your page style sheets

6.73.9. Skin parameters redefinition:

There is only one skin parameter for the tree since <rich:tree> is a wrapper component for tree nodes. Look and feel is described in details in the "treeNode" chapter.

Table 6.246. Skin parameters for wrapper element

Skin parameters for wrapper elementProperties corresponding to CSS parameter
overAllBackgroundbackground-color

6.73.10. Definition custom style classes

The tree also has only one predefined Style Class responsible for displaying a wrapper element of the tree - <rich:tree> redefining of which will change look and feel of all trees on the page.

6.73.11. Relevant resources links

Here you can see the example of <rich:tree> usage and sources for the given example.

How to Expand/Collapse Tree Nodes from code, see here.

6.74.  < rich:treeNode >

6.74.1. Description

A component is used for designing templates for nodes definition.

TreeNode component

Figure 6.103. TreeNode component


6.74.2. Key Features

Table 6.247. rich : treeNode attributes

Attribute NameDescription
acceptedTypesList of drag types to be processed by the current drop zone
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
ajaxSubmitSelectionAn algorithm of AJAX request submission. "inherit", "true", "false" values are possible
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
changeExpandListenerListener called on expand/collapse event on the node
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
dragIndicatorId of the dragIndicator component used as drag operation cursor
dragListenerMethodBinding representing an action listener method that will be notified after drag operation
dragTypeKey of a drag object. It's used to define a necessity of processing the current dragged element on the drop zone side
dragValueData to be sent to the drop zone after a drop event
dropListenerMethodBinding representing an action listener method that will be notified after drop operation
dropValueData to be processed after a drop event
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
highlightedClassCorresponds to the HTML class attribute. Applied to highlighted node
iconThe icon for node
iconCollapsedThe icon for collapsed node
iconExpandedThe icon for expanded node
iconLeafAn icon for component leaves
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
nodeClassName of node CSS class
nodeSelectListenerMethodBinding representing an action listener method that will be notified after selection of node.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncollapseHTML: script expression to invoke on node collapsing
oncompleteJavaScript code for call after request completed on client side
oncontextmenuJavaScript handler to be called on right click. Returning false prevents default browser context menu from being displayed
ondblclickHTML: a script expression; a pointer button is double-clicked
ondragendA JavaScript event handler called after a drag operation
ondragenterA JavaScript event handler called on enter draggable object to zone
ondragexitA JavaScript event handler called after a drag object leaves zone
ondragstartA JavaScript event handler called before drag object
ondropIt's an event that is called when something is dropped on a drop zone
ondropendA JavaScript handler for event fired on a drop even the drop for a given type is not available
onexpandHTML: script expression to invoke on node expansion
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectedHTML: script expression to invoke on node selection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
selectedClassCorresponds to the HTML class attribute. Applied to selected node
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
typeA node type
typeMappingMap between a draggable type and an indicator name on zone. it's defined with the pair (drag type:indicator name))

Table 6.248. Component identification parameters

NameValue
component-typeorg.richfaces.TreeNode
component-classorg.richfaces.component.html.HtmlTreeNode
component-familyorg.richfaces.TreeNode
renderer-typeorg.richfaces.TreeNodeRenderer
tag-classorg.richfaces.taglib.TreeNodeTag

6.74.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:tree ... faceNode="simpleNode">
        <rich:treeNode type="simpleNode">
            <!--Tree node data displaying template-->
        </rich:treeNode>
    </rich:tree>
...

6.74.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlTreeNode;
...
HtmlTreeNode myPanel = new HtmlTreeNode();
...

6.74.5. Details of Usage

The "icon" , "iconCollapsed" , "iconExpanded" , "iconLeaf" attributes define icons for the component. Also you can define icons using facets with the same names. If the facets are defined, the corresponding attributes are ignored and facets contents are used as icons. The width of a rendered facet area is 16px.


...
    <rich:tree ...>
        ...
        <rich:treeNode ...>
            <f:facet name="icon">
                <hutputText value="A"/>
            </f:facet>
            <f:facet name="iconCollapsed">
                <hutputText value="B"/>
            </f:facet>      
            <f:facet name="iconExpanded">
                <hutputText value="C"/>
            </f:facet>
            <f:facet name="iconLeaf">
                <hutputText value="D"/>
            </f:facet>
        </rich:treeNode>
        ...
    </rich:tree>
...

6.74.6. Look-and-Feel Customization

As it has been mentioned above, treeNode defines a template for nodes rendering in a tree. Thus, during XML document rendering (a web.xml application) as a tree, the following nodes output (passed via var="data" on a tree) happens:

Example:


...
    <rich:tree ... faceNode="simpleNode" ... value="#{bean.data}" var="data">
        <rich:treeNode type="simpleNode">
            <h:outputText value="context-param:"/>
            <h:inputText value="#{data.name}"/>
        </rich:treeNode>
    </rich:tree >
...
Nodes output

Figure 6.104. Nodes output


Hence, outputText outputs the "context-param" string and then the input is output for the data.name element of this node.

Different nodes for rendering could be defined depending on some conditions on the tree level. Each condition represents some rendering template. To get more information on various treeNodesAdaptorAdaptor definition for nodes, see the tree component chapter.

Switching between expanded/collapsed modes is also managed on the tree level and defined in the corresponding section.

Default nodes of the tree level as well as ones defined with the treeNodesAdaptorAdaptor component could send Ajax requests when selected with the mouse, it's managed with the "ajaxSubmitSelection" attribute (true/false).

6.74.7. Built-in Drag and Drop

The main information on Drag and Drop operations is given in the corresponding paragraph of the tree component chapter. It's only necessary to mention that each node could also be a Drag element as well as a Drop container, i.e. the container and the element have all attributes, listeners and ways of behavior similar to the ones of the <rich:draggable> and <rich:dropZone> components simultaneously.

6.74.8. Events Handling

Just as Drag and Drop operations it corresponds to the one described on the tree component level for a default Node.

6.74.9. Look-and-Feel Customization

For skinnability implementation the components use a style class redefinition method .

Default style classes are mapped on skin parameters.

To redefine appearance of all treeNodesAdaptor at once, there are two ways:

  • to redefine corresponding skin parameters
  • to add style classes used by the treeNode to your page style sheets

6.74.10. Skin parameters redefinition:

Table 6.249. Default skins for treeNode element

Default skins for treeNode elementProperties corresponding to CSS parameter
panelTextColorcolor
preferableDataSizeFontfont-size
preferableDataFamilyFontfont-family

Table 6.250. Skin parameters for selected Node element

Skin parameters for selected Node elementProperties corresponding to CSS parameter
headerBackgroundColorbackground-color
headerBackgroundColorbackground-color
headTextColorcolor

Table 6.251. Skin parameters for mouseovered Node element

Skin parameters for mouseovered Node elementProperties corresponding to CSS parameter
selectControlColorcolor

Hence, to change look and feel of all treeNodesAdaptor components on an application, change these parameters values.

6.74.11. Definition custom style classes

The following classes are applied to a node element in three states: default, marked, mouseovered:

  • rich-tree-node
  • rich-tree-node-selected
  • rich-tree-node-highlighted

Hence, in order to change an appearance of all treeNodesAdaptor on a page, declare and customize the above-mentioned classes in your CSS.

It is also possible to change look and feel of specific treeNodesAdaptor with the help of defining for them "selectedClass" and "highlightedClass" attributes by their specific classes.

6.74.12. Relevant resources links

How to Expand/Collapse Tree Nodes from code see here.

6.75.  < rich:changeExpandListener >

6.75.1. Description

The <rich:changeExpandListener> represents an action listener method that is notified on an expand/collapse event on the node.

6.75.2. Key Features

  • Allows to define some "changeExpand" listeners for the component

Table 6.252. rich : changeExpandListener attributes

Attribute NameDescription
binding The attribute takes a value-binding expression for a component property of a backing bean
type Attribute defines the fully qualified Java class name for listener

Table 6.253. Component identification parameters

NameValue
listener-classorg.richfaces.event.NodeExpandedListener
event-classorg.richfaces.event.NodeExpandedEvent
tag-classorg.richfaces.taglib.ChangeExpandListenerTag

6.75.3. Creating on a page

Simple Component definition on a page:

Example:


...
    <rich:changeExpandListener type="demo.Bean"/>
...

6.75.4. Dynamical creation of a component from Java code

Example:


package demo;
      
public class ImplBean implements org.richfaces.event.NodeExpandedListener{
    ...
}


import demo.ImplBean;
...
ImplBean myListener = new ImplBean();
...

6.75.5. Key attributes and ways of usage

The <rich:changeExpandListener> is used as a nested tag with <rich:tree> and <rich:treeNode> components.

Attribute "type" defines the fully qualified Java class name for the listener. This class should implement org.richfaces.event.NodeExpandedListener interface.

The typical variant of using:


...
<rich:tree switchType="server" value="#{project.data}" var="item" nodeFace="#{item.type}">
    <rich:changeExpandListener type="demo.ListenerBean"/>
    ...
    <!-- Tree nodes --> 
    ...
</rich:tree>
...

Java bean source:


package demo;

import org.richfaces.event.NodeExpandedEvent;

public class ListenerBean implements org.richfaces.event.NodeExpandedListener{
... 
    public void processExpansion(NodeExpandedEvent arg0){
        //Custom Developer Code 
    }
...
}

6.76.  < rich:nodeSelectListener >

6.76.1. Description

The <rich:nodeSelectListener> represents an action listener method that will be notified after selection of node.

6.76.2. Key Features

  • Allows to define some "nodeSelect" listeners for the component

Table 6.254. rich : nodeSelectListener attributes

Attribute NameDescription
binding The attribute takes a value-binding expression for a component property of a backing bean
type Attribute defines the fully qualified Java class name for listener

Table 6.255. Component identification parameters

NameValue
listener-classorg.richfaces.event.NodeSelectedListener
event-classorg.richfaces.event.NodeSelectedEvent
tag-classorg.richfaces.taglib.NodeSelectListenerTag

6.76.3. Creating on a page

Simple Component definition on a page:

Example:


...
    <rich:nodeSelectListener type="demo.Bean"/>
...

6.76.4. Dynamical creation of a component from Java code

Example:


package demo;
      
public class ImplBean implements org.richfaces.event.NodeSelectListener{
    ...
}


import demo.ImplBean;
...
ImplBean myListener = new ImplBean();
...

6.76.5. Key attributes and ways of usage

The <rich:nodeSelectListener> is used as nested tag with <rich:tree> and <rich:treeNode> components.

Attribute "type" defines the fully qualified Java class name for listener. This class should implement org.richfaces.event.NodeSelectedListener interface.

The typical variant of using:


...
<rich:tree switchType="server" value="#{project.data}" var="item" nodeFace="#{item.type}">
    <rich:nodeSelectListener type="demo.ListenerBean"/>
    ...
    <!-- Tree nodes --> 
    ...
</rich:tree>
...

Java bean source:


package demo;

import org.richfaces.event.NodeSelectedEvent;

public class ListenerBean implements org.richfaces.event.NodeSelectedListener{
... 
    public void processSelection(NodeSelectedEvent arg0){
        //Custom Developer Code 
    }
...
}

6.77.  < rich:treeNodesAdaptor >

6.77.1. Description

The rich:treeNodesAdaptor provides possibility to define data models and create representations for them.

Expanded tree with treeNodesAdaptor

Figure 6.105. Expanded tree with treeNodesAdaptor


6.77.2. Key Features

  • Allows to define combined data models
  • Possibility to define nodes for processing via attributes

Table 6.256. rich : treeNodesAdaptor attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
includedNodeThis boolean expression is used to define which elements are processed
nodesDefines collection to use at the other (non-top) levels of iteration
renderedIf "false", this component is not rendered
varA request-scope attribute via which the data object for the current collection element will be used when iterating

Table 6.257. Component identification parameters

NameValue
component-typeorg.richfaces.TreeNodesAdaptor
component-classorg.richfaces.component.html.HtmlTreeNodesAdaptor
component-familyorg.richfaces.TreeNodesAdaptor
tag-classorg.richfaces.taglib.TreeNodesAdaptorTag

6.77.3. Creating the Component with a Page Tag

To create the simplest variant of rich:treeNodesAdaptor on a page, use the following syntax:

Example:


...
<rich:treeNodesAdaptor var="issue" nodes="#{model.issues}">
    ...
    <rich:treeNode>
        <!-- node content -->                           
    </rich:treeNode>
    ... 
    <!-- Others nodes -->                           
    ...
</rich:treeNodesAdaptor>
...

6.77.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlTreeNodesAdaptor;
...
HtmlTreeNodesAdaptor myTreeNodesAdaptor = new HtmlTreeNodesAdaptor();
...

6.77.5. Details of Usage

The typical variant of using:


...
    <rich:tree adviseNodeOpened="#{treeModelBean.adviseNodeOpened}" switchType="client">
        <rich:treeNodesAdaptor id="project" nodes="#{loaderBean.projects}" var="project">
            <rich:treeNode>
                <h:commandLink action="#{project.click}" value="Project: #{project.name}" />
            </rich:treeNode>
            <rich:treeNodesAdaptor id="srcDir" var="srcDir" nodes="#{project.srcDirs}">
                <rich:treeNode>
                    <h:commandLink action="#{srcDir.click}" value="Source directory: #{srcDir.name}" />
                </rich:treeNode>
                <rich:treeNodesAdaptor id="pkg" var="pkg" nodes="#{srcDir.packages}">
                    <rich:treeNode>
                        <h:commandLink action="#{pkg.click}" value="Package: #{pkg.name}" />
                    </rich:treeNode>
                    <rich:treeNodesAdaptor id="class" var="class" nodes="#{pkg.classes}">
                        <rich:treeNode>
                            <h:commandLink action="#{class.click}" value="Class: #{class.name}" />
                        </rich:treeNode>
                    </rich:treeNodesAdaptor>    
                </rich:treeNodesAdaptor>
            </rich:treeNodesAdaptor>
        </rich:treeNodesAdaptor>
    </rich:tree>
...

6.77.6. Relevant resources links

Here you can see the example of <rich:treeNodesAdaptor > usage and sources for the given example.

6.78.  < rich:recursiveTreeNodesAdaptor >

6.78.1. Description

The rich:recursiveTreeNodesAdaptor provides possibility to define data models and process nodes recursively.

Expanded tree with recursiveTreeNodesAdaptor

Figure 6.106. Expanded tree with recursiveTreeNodesAdaptor


6.78.2. Key Features

  • Allows to define combined data models
  • Possibility to define nodes for processing via attributes
  • Allows to process nodes recursively

Table 6.258. rich : recursiveTreeNodesAdaptor attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
includedThis boolean expression is used to define which elements of both collections are processed
includedNodeThis boolean expression is used to define which elements are processed
includedRootThis boolean expression is used to define which elements are processed appling to "roots" collection
nodesDefines collection to use at the other (non-top) levels of iteration
renderedIf "false", this component is not rendered
rootsDefines collection to use at the top of iteration
varA request-scope attribute via which the data object for the current collection element will be used when iterating

Table 6.259. Component identification parameters

NameValue
component-typeorg.richfaces.RecursiveTreeNodesAdaptor
component-classorg.richfaces.component.html.HtmlRecursiveTreeNodesAdaptor
component-familyorg.richfaces.RecursiveTreeNodesAdaptor
tag-classorg.richfaces.taglib.RecursiveTreeNodesAdaptorTag

6.78.3. Creating the Component with a Page Tag

To create the simplest variant of rich:recursiveTreeNodesAdaptor on a page, use the following syntax:

Example:


...
    <rich:recursiveTreeNodesAdaptor var="issue" root="#{project.root}" nodes="#{model.issues}">
        ...
        <rich:treeNode>
             <!-- node content -->
        </rich:treeNode>
        
        <!-- Others nodes -->   
        ...
    </rich:recursiveTreeNodesAdaptor>
...

6.78.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlRecursiveTreeNodesAdaptor;
...
HtmlRecursiveTreeNodesAdaptor myRecursiveTreeNodesAdaptor = new HtmlRecursiveTreeNodesAdaptor();
...

6.78.5. Details of Usage

The typical variant of using:


...
<rich:tree adviseNodeOpened="#{treeModelBean.adviseNodeOpened}" switchType="client">
    <rich:treeNodesAdaptor id="project" nodes="#{loaderBean.projects}" var="project">
        
        <rich:treeNode>
            <h:commandLink action="#{project.click}" value="Project: #{project.name}" />
        </rich:treeNode>

        <rich:recursiveTreeNodesAdaptor id="dir" var="dir" root="#{project.dirs}" nodes="#{dir.directories}">
            
            <rich:treeNode>
                <h:commandLink action="#{dir.click}" value="Directory: #{dir.name}" />
            </rich:treeNode>
            
            <rich:treeNodesAdaptor id="file" var="file" nodes="#{dir.files}">
                <rich:treeNode>
                    <h:commandLink action="#{file.click}" value="File: #{file.name}" />
                </rich:treeNode>
            </rich:treeNodesAdaptor>
            
            <rich:treeNodesAdaptor id="file1" var="file" nodes="#{dir.files}">
                <rich:treeNode>
                    <h:commandLink action="#{file.click}" value="File1: #{file.name}" />
                </rich:treeNode>
            </rich:treeNodesAdaptor>

            <rich:recursiveTreeNodesAdaptor id="archiveEntry" var="archiveEntry"
                roots="#{dir.files}" nodes="#{archiveEntry.archiveEntries}" 
                includedRoot="#{archiveEntry.class.simpleName == 'ArchiveFile'}"
                includedNode="#{archiveEntry.class.simpleName == 'ArchiveEntry'}">
            
                <rich:treeNode id="archiveEntryNode">
                    <h:commandLink action="#{archiveEntry.click}" value="Archive entry: #{archiveEntry.name}" />
                </rich:treeNode>
                
            </rich:recursiveTreeNodesAdaptor>
            
        </rich:recursiveTreeNodesAdaptor>
    </rich:treeNodesAdaptor>
</rich:tree>
...