Note that there are some explanatory texts on larger screens.

plurals
  1. PORichfaces rich:validator not marking UIInput invalid during client-side validation
    text
    copied!<p>I'm using rich:validator for JSR-303 validation on an inputText as follows:</p> <pre><code>&lt;h:outputLabel value="#{msgs['label.email']}:"/&gt; &lt;h:inputText value="#{loginBean.email}" id="email" size="50" validatorMessage="Invalid email address." styleClass="#{component.valid ? '' : 'invalid'}"&gt; &lt;rich:validator /&gt; &lt;/h:inputText&gt; &lt;rich:message for="email" /&gt; </code></pre> <p>When validation fails the class of the inputText is supposed to change to <code>invalid</code>, which causes a red border around the component to appear, and the rich:message is supposed to display the <code>Invalid email address</code> message. If I enter an invalid email address and move the mouse cursor outside of the inputText only the <code>Invalid email address</code> message appears; the UIInput does not switch to the <code>invalid</code> class, so no red border appears around the component. However, if I click the submit button and submit the form with an invalid email address, when the page is reloaded the inputText box's class changes and I get both the red-bordered component as well as the error message. Why is this so? Doesn't JSR-303 require that client-side validation work just the same as if the form were to be submitted?</p> <p><strong>EDIT:</strong></p> <p>I added the following to my inputText, which resolved the problem with changing the class on the inputText:</p> <pre><code> &lt;a4j:ajax event="blur" render="email"/&gt; </code></pre> <p>However, this introduced a new problem. Now, the error messages are not "sticky." In other words, when an invalid email is entered the red outline appears on the inputText and the error message appears, as expected, but if I then enter an invalid input on another component and it's class changes to "invalid" and its error message appears, the error message on "email" disappears. The inputText class change works fine now, but the messages are volatile, and they disappear if another component's entry becomes invalid.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload