Pavlo Bazilnskyy
Pavlo Bazilnskyy

Reputation: 336

Disable rerendering of input field after validation message is shown

Is it possible to disable rerendering of an input field after a message of failed validation is shown?

This is a piece of my view:

<h:outputLabel for="captcha" value="#{ui.pleaseEnterTextInTheImage}"  rendered="#{sessionBean.showCaptcha}"/>
<h:panelGroup rendered="#{sessionBean.showCaptcha}">
     <h:inputText id="captcha" styleClass="captcha" validator="#{validationBean.captchaValidator}" />
     <h:outputText value=" "/><h:message for="captcha" styleClass="captchaMsg"/>
</h:panelGroup>

Upvotes: 0

Views: 544

Answers (1)

BalusC
BalusC

Reputation: 1109715

Yes, bind the to-be-validated input component to the view and check UIInput#isValid() in the rendered condition.

<h:inputText binding="#{captcha}" required="true" />
...
<h:inputText rendered="#{captcha.valid}" />

The second will disappear upon form submit when the first has a validation error.

Upvotes: 1

Related Questions