Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger JSF validation using ajax after focus lost

How do you trigger validation on an input component when the component loses focus using ajax instead of waiting for the form to be manually submitted?

like image 323
Farouk Alhassan Avatar asked Apr 26 '11 08:04

Farouk Alhassan


1 Answers

Put a <f:ajax event="blur"> in the UIInput component which re-renders a <h:message> associated with the component in question.

<h:inputText id="foo" value="#{bean.foo}" required="true">
    <f:ajax event="blur" render="fooMessage" />
</h:inputText>
<h:message id="fooMessage" />

See also JSF 2.0 tutorial with Eclipse and Tomcat - the view and finetuning validation

like image 147
BalusC Avatar answered Oct 11 '22 23:10

BalusC