The <o:messages>
is a component that extends the standard <h:messages>
with the following new features:
for
componentsfor
attribute. The example below would only display messages for input1
and input3
: <h:form> <o:messages for="input1 input3" /> <h:inputText id="input1" /> <h:inputText id="input2" /> <h:inputText id="input3" /> <h:inputText id="input4" /> </h:form>It can even refer non-input components which in turn contains input components. The example below would only display messages for
input1
and input2
: <h:form> <o:messages for="inputs" /> <h:panelGroup id="inputs"> <h:inputText id="input1" /> <h:inputText id="input2" /> </h:panelGroup> <h:inputText id="input3" /> <h:inputText id="input4" /> </h:form>You can even combine them. The example below would only display messages for
input1
, input2
and input4
. <h:form> <o:messages for="inputs input4" /> <h:panelGroup id="inputs"> <h:inputText id="input1" /> <h:inputText id="input2" /> </h:panelGroup> <h:inputText id="input3" /> <h:inputText id="input4" /> </h:form>
for
specified components has a faces message. For example: <o:messages for="form" message="There are validation errors. Please fix them." /> <h:form id="form"> <h:inputText id="input1" /><h:message for="input1" /> <h:inputText id="input2" /><h:message for="input2" /> <h:inputText id="input3" /><h:message for="input3" /> </h:form>
escape
attribute. <o:messages escape="false" />Beware of potential XSS attack holes when user-controlled input is redisplayed through messages!
var
attribute which sets the current {@link FacesMessage}in the request scope and disables the default table/list rendering. For example, <dl> <o:messages var="message"> <dt>#{message.severity}</dt> <dd title="#{message.detail}">#{message.summary}</dd> </o:messages> </dl>Note: the iteration is by design completely stateless. It's therefore not recommended to nest form components inside the
<o:messages>
component. It should be used for pure output only, like as the standard <h:messages>
. Plain output links are however no problem. Also note that the message
and escape
attributes have in this case no effect. With a single message, there's no point of iteration. As to escaping, just use <h:outputText escape="false">
the usual way. Design notice: the component class is named OmniMessages
instead of Messages
to avoid confusion with the {@link Messages} utility class.
@author Bauke Scholtz
@since 1.5
@see MessagesRenderer
|
|