JBoss.orgCommunity Documentation

Chapter 14. Output and messages

14.1. <rich:message>
14.1.1. Basic usage
14.1.2. Appearance
14.1.3. Reference data
14.2. <rich:messages>
14.2.1. Basic usage
14.2.2. Appearance
14.2.3. Reference data
14.3. <rich:progressBar>
14.3.1. Basic usage
14.3.2. Customizing the appearance
14.3.3. Using set intervals
14.3.4. Update mode
14.3.5. Reference data
14.4. <rich:toolTip>
14.4.1. Basic usage
14.4.2. Attaching the tool-tip to another component
14.4.3. Appearance
14.4.4. Update mode
14.4.5. <rich:toolTip> client-side events
14.4.6. Reference data

Documentation in development

Some concepts covered in this chapter may refer to the previous version of Richfaces, version 3.3.3. This chapter is scheduled for review to ensure all information is up to date.

Read this chapter for details on components that display messages and other feedback to the user.

The <rich:message> component renders a single message relating to another specific component. The message consists of two parts, both of which are optional: the marker icon and the textual label. The appearance of the message can be customized, and tool-tips can be used for further information about the message.

Figure 14.1. rich:message component


The <rich:messages> components works similarly to the <rich:message> component, but can display validation messages for a group of components instead of just a single component. Refer to Section 14.1, “<rich:message>” for details on the <rich:message> component.

Figure 14.2. rich:messages component


The <rich:messages> component displays error messages for each validating component in the same container. The passedLabel attribute contains a message to display when there are no errors; that is, when validation for all components passes successfully. The layout attribute defines how the messages are presented: either using list for a list layout, or table for a tabular layout.

All messages use the same state icons, specified by using facets in the same way as for the <rich:message> component:

Example 14.2. rich:messages example


<h:form>
    <rich:messages passedLabel="Data validated." layout="list">
        <f:facet name="header">
            <h:outputText value="Entered Data Status:"></h:outputText>
        </f:facet>
        <f:facet name="passedMarker">
            <h:graphicImage  value="/images/ajax/passed.gif" /> 
        </f:facet>
        <f:facet name="errorMarker">
            <h:graphicImage value="/images/ajax/error.gif" />   
        </f:facet>
    </rich:messages>

    <h:panelGrid columns="2">
        <h:outputText value="Name:" />
        <h:inputText label="Name" id="name" required="true" value="#{userBean.name}">
            <f:validateLength minimum="3"  />
        </h:inputText>
        <h:outputText value="Job:" />
        <h:inputText label="Job" id="job" required="true" value="#{userBean.job}">
            <f:validateLength minimum="3" maximum="50"  />
        </h:inputText>
        <h:outputText value="Address:" />
        <h:inputText label="Address" id="address" required="true" value="#{userBean.address}">
            <f:validateLength minimum="10" />
        </h:inputText>
        <h:outputText value="Zip:" />
        <h:inputText label="Zip" id="zip" required="true" value="#{userBean.zip}">
            <f:validateLength minimum="4" maximum="9"  />
        </h:inputText>
        <f:facet name="footer">
            <a4j:commandButton value="Validate" />
        </f:facet> 
    </h:panelGrid>
</h:form>

    

The <rich:progressBar> component displays a progress bar to indicate the status of a process to the user. It can update either through Ajax or on the client side, and the look and feel can be fully customized.

Figure 14.3. <rich:progressBar>


By default, the minimum value of the progress bar is 0 and the maximum value of the progress bar is 100. These values can be customized using the minValue and maxValue attributes respectively.

The progress bar can be labeled in one of two ways:

For labeling, the <rich:progressBar> component recognizes three macro-substitution parameters:


Additionally, you can use the {param} parameter to specify any custom parameters you require. Define the parameters in the bean for the progress method, then reference it with the <rich:progressBar> component's parameters attribute, as shown in Example 14.7, “Using the param parameter”.


To define customized initial and complete states for the progress bar, use the initial and complete facets. The initial facet displays when the progress value is less than or equal to the minimum value, and the complete facet displays when the progress value is greater than or equal to the maximum value.


The <rich:toolTip> component provides an informational tool-tip. The tool-tip can be attached to any control and is displayed when hovering the mouse cursor over the control.

Figure 14.4. <rich:toolTip>