Reputation: 5554
I want to show a primefaces overlay with search suggestions using p:ajax
like following:
<p:inputText value="#{bean.input}" required="true"
validatorMessage="Add at least 3 characters">
<f:validateLength minimum="3" maximum="64"/>
<p:ajax event="keyup" delay="200" process="@this"
listener="#{bean.createSuggestions()}"
update="overlay"
oncomplete="showOverlay()"/>
</p:inputText>
The problem is, that no validation takes place.
I could use javascript onstart handler and check input again as a workaround.
Upvotes: 1
Views: 1042
Reputation: 1109625
Execute p:ajax only if input is valid
That's only possible if you validate in client side, as you already figured for the workaround.
The alternative would be to execute oncomplete
only when there's no validation error.
oncomplete="if (args && !args.validationFailed) showOverlay()"
The doublecheck and ugly XML escaping is necessary for reasons mentioned here: Keep p:dialog open when a validation error occurs after submit.
Upvotes: 3