Reputation: 11
After at all, I´m sorry for my english. I have a problem showing a modalPanel. I would like show a modalPanel if the validation of the form was correct and doesn´t show it if the validation fail.
<h:form>
<rich:calendar id="date" datePattern="dd-MM-yyyy"
value="#{Bean.startDate}" required="true"/>
<a4j:commandButton value="Accept" action="#{Bean.Action}"
onclick="if(#{empty facesContext.maximumSeverity}) #{rich:component('popUp')}.show();" />
</form>
The maximumSeverity doesn´t work here because when the page load at first time, maximumSeverity is empty.
Is possible call the validation of the lifecycle of JSF to know if the form is correct or not?
Thanks!
Upvotes: 1
Views: 1901
Reputation: 1108577
The onclick
runs before the action is invoked. You need oncomplete
instead.
If you're using JSF 2.0, it's by the way better to use FacesContext#isValidationFailed()
instead as normal INFO messages also count in the severity.
<a4j:commandButton value="Accept" action="#{Bean.Action}"
oncomplete="if(#{not facesContext.validationFailed}) #{rich:component('popUp')}.show();" />
Upvotes: 3