Ajax event never fires in <p: inptText> if necessary = "true"

In PrimeFaces, when I use:

<p:inputText required="true" requiredMessage="message" value="#{backingBean.value}"> <p:ajax event="focus" update="infoText" listener="#{backingBean.something()}" /> </p:inputText> 

Ajax event never fires. However, if I delete the required value = "true", everything works fine and the event fires.

Can someone tell me how to use p: inputText with p: ajax and required = "true"?

+4
source share
1 answer

This probably happens because when you focus on the text field, an ajax event occurs that sends the ViewState back to the components on the page.

When he does this, he tries to set the current value of the text field to #{backingBean.value} , which is empty, resulting in a ValidatorException. Because a validation error occurred, the action event #{backingBean.something()} never fires.

Try adding the immediate="true" property to the <p:ajax> and see if this event fires before the verification phase.

+3
source

All Articles