I am using JSF2, Richfaces4 and Spring. I have a command link. On execute I save records and on complete I execute search to display records like following code.
Problem is that fireSearch() in oncomplete executes even if there is a validation error in form. I need to execute fireSearch() only when the record get saved successfully.
How can I the oncomplete only when validation has succeed?
<a4j:commandLink styleClass="button" action="#{myBean.save}" render="detail_form" execute="@form" oncomplete="fireSearch()">
<span> Save </span>
</a4j:commandLink>
RichFaces supports request based EL evaluation in
oncompleteattribute. So you should be able to printFacesContext#isValidationFailed()as if it’s a JS condition.For example,
If validation has failed, this will ultimately result in
And thus the function won’t be invoked.