Checking JSF and Ajax. How to update message panels for ALL messages?

I want to check all input fields using AJAX.

For example, there are 3 input fields. Two of them require a minimum length of 3 characters, and the other is checked by a simple regular expression. For, <f:ajax>I set up a keyup event to quickly see how ajax validation approaches. A complete example might look like this:

   <h:form>
       <h:messages id="messages" />
       <h:inputText id="text1" value="#{bean.text1}">
           <f:validateLength minimum="3" />
           <f:ajax execute="@this" event="keyup" render="messages" />
       </h:inputText>

       <h:inputText id="text2" value="#{bean.text2}">
           <f:validateLength minimum="3" />
           <f:ajax execute="@this" event="keyup" render="messages" />
       </h:inputText>

        <h:inputText id="text3" value="#{bean.text3}">
            <f:validateRegex pattern="[A-Z][a-zA-Z]*" />
            <f:ajax execute="@this" event="keyup" render="messages" />
        </h:inputText>
    </h:form>

As soon as I leave the input field with an error and go to the second field and print invalid data there, the message from the first invalid field will disappear, because the messages are reloaded! The execution task for @form will cause all fields to be checked as soon as I start typing in the first input field.

, : AJAX, ?

P.S.: Im, Mojarra 2.0.3 (+ Richfaces + Primefaces) Websphere

+3
1

. , , .

<h:form>
    <h:panelGrid columns="2">
        <h:inputText id="text1" value="#{bean.text1}">
            <f:validateLength minimum="3" />
            <f:ajax event="keyup" render="text1message" />
        </h:inputText>
        <h:message id="text1message" for="text1" />

        <h:inputText id="text2" value="#{bean.text2}">
            <f:validateLength minimum="3" />
            <f:ajax event="keyup" render="text2message" />
        </h:inputText>
        <h:message id="text2message" for="text2" />

        <h:inputText id="text3" value="#{bean.text3}">
            <f:validateRegex pattern="[A-Z][a-zA-Z]*" />
            <f:ajax event="keyup" render="text3message" />
        </h:inputText>
        <h:message id="text3message" for="text3" />
    </h:panelGrid>
</h:form>

.

+7

All Articles