6.36.  < rich:dataDefinitionList >

6.36.1. Description

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

<rich:dataDefinitionList> component

Figure 6.60.  <rich:dataDefinitionList> component


6.36.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.131. rich : dataDefinitionList attributes

Attribute NameDescription
ajaxKeysThis attribute defines row keys 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
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
rowKeyConverterConverter for a row key object
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.132. 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.36.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">Cars</f:facet>
        <h:outputText value="#{car.model}"/>
    </rich:dataDefinitionList>
...

6.36.4. Creating the Component Dynamically Using Java

Example:


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

6.36.5. Details of Usage

The <rich:dataDefinitionList> component allows to generate an definition list from a model.

The component has the "term" facet, which corresponds to the "type" parameter for the "DT" HTML element.

Here is an example:


...
    <h:form>
        <rich:dataDefinitionList var="car" value="#{dataTableScrollerBean.allCars}" rows="5" first="4" title="Cars">
            <f:facet name="term">
                <h:outputText value="#{car.make} #{car.model}"></h:outputText>
            </f:facet>
            <h:outputText value="Price:" styleClass="label"></h:outputText>
            <h:outputText value="#{car.price} " /><br/>
            <h:outputText value="Mileage:" styleClass="label"></h:outputText>
            <h:outputText value="#{car.mileage} " /><br/>
        </rich:dataDefinitionList>
    </h:form>
...

This is a result:

<rich:dataDefinitionList> component with "term" facet

Figure 6.61.  <rich:dataDefinitionList> component with "term" facet


In the example the "rows" attribute limits number of output elements of the list.

"first" attribute defines first element for output. "title" are used for popup title.

The component was created basing on the <a4j:repeat> component and as a result it could be partially updated with Ajax. "ajaxKeys" attribute allows to define row keys that are updated after an Ajax request.

Here is an example:

Example:


...
    <rich:dataDefinitionList value="#{dataTableScrollerBean.allCars}" var="car" ajaxKeys="#{listBean.list}" 
                        binding="#{listBean.dataList}" id="list">
        ...
    </rich:dataDefinitionList>
...
    <a4j:commandButton action="#{listBean.action}" reRender="list" value="Submit"/>
...

In the example "reRender" attribute contains value of "id" attribute for <rich:dataDefinitionList> component. As a result the component is updated after an Ajax request.

6.36.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:dataDefinitionList> components at once:

  • Redefine the corresponding skin parameters

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

6.36.7. Definition of Custom Style Classes

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

Style classes

Figure 6.62. Style classes


Table 6.133. 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

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

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

6.36.8. Relevant Resources Links

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