public class MessagesKeywordResolver extends SearchKeywordResolver
@messages search keyword resolver will automatically resolve all
UIMessages components within the current
UIForm. This is particularly useful when you have a relatively large form and
would like to Ajax-update only the message components when submitting the form.
<h:form id="form"> <h:inputText id="input1" ... /> <h:message id="m_input1" for="input1" /> <h:inputText id="input2" ... /> <h:message id="m_input2" for="input2" /> <h:inputText id="input3" ... /> <h:message id="m_input3" for="input3" /> ... <h:commandButton ...> <f:ajax execute="@form" render="@messages" /> </h:commandButton> <h:messages id="m_form" globalOnly="true" redisplay="false" /> </h:form>
This has only one prerequirement: the message component must have a fixed
id attribute set as demonstrated above. Otherwise
processing the JSF Ajax response.
This keyword resolver is already registered by OmniFaces own
faces-config.xml and thus gets auto-initialized when the
OmniFaces JAR is bundled in a web application, so end-users do not need to register this keyword resolver explicitly themselves.
This keyword resolver is only compatible with
<f:ajax> of Mojarra 2.3.4 or newer.
This keyword resolver is not compatible with
<p:ajax> of PrimeFaces 6.x.
It's only compatible with a PrimeFaces version designed specifically for JSF 2.3.
|Constructor and Description|
|Modifier and Type||Method and Description|
public static void register(Application application)
application- Involved faces application.
public boolean isResolverForKeyword(SearchExpressionContext context, String keyword)
truewhen keyword equals "messages".
public void resolve(SearchKeywordContext context, UIComponent component, String keyword)
UIForm, visit it and collect client IDs of all
UIMessagescomponents and finally invoke context call back with an
UIMessagecomponent whose client ID returns a space separated collection of found client IDs.
Copyright © 2012–2018 OmniFaces. All rights reserved.