6.61.  < rich:messages >

6.61.1. Description

The <rich:messages> component is similar to <rich:message> component but used for rendering all messages for the components.

<rich:messages> component

Figure 6.148.  <rich:messages> component


6.61.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.288. 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"
levelcomma-separated list of messages categoris which should be displayed
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.289. 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.61.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.61.4. Creating the Component Dynamically Using Java

Example:


import  org.richfaces.component.html.HtmlRichMessages;
...
HtmlRichMessages myMessages = new HtmlRichMessages();
...

6.61.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.png"/>
        </f:facet>
        <f:facet name="infoMarker">
            <h:graphicImage url="/image/info.png"/>
        </f:facet>
        <f:facet name="passedMarker">
            <h:graphicImage url="/image/passed.png"/>
        </f:facet> 
    </rich:messages>
...

6.61.6. Look-and-Feel Customization

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

There are no skin parameters and default predefined values. To redefine the appearance of all <rich:messages> components at once, you should only add to your style sheets style classes used by a <rich:messages> component.

6.61.7. Definition of Custom Style Classes

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

Classes names

Figure 6.149. Classes names


Table 6.290. Classes names that define a component appearance

Class nameDescription
rich-messagesDefines styles for a wrapper element
rich-messages-markerDefines styles for a marker
rich-messages-labelDefines styles for a label

In order to redefine styles for all <rich:messages> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-messages-label{
    
font-style:italic;
}
...

This is a result:

Redefinition styles with predefined classes

Figure 6.150. Redefinition styles with predefined classes


In the example the font style for messages was changed.

Also it’s possible to change styles of particular <rich:messages> component. In this case you should create own style classes and use them in corresponding <rich:messages> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
color:red;
}

...

The "errorClass" attribute for <rich:messages> is defined as it’s shown in the example below:

Example:


<rich:messages ... errorClass="myClass"/>

This is a result:

Redefinition styles with own classes and styleClass attributes

Figure 6.151. Redefinition styles with own classes and styleClass attributes


As it could be seen on the picture above, color of messages was changed.

6.61.8. Relevant Resources Links

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