-
Available since OmniFaces 1.0
The <o:ignoreValidationFailed>
taghandler allows the developer to ignore validation failures when executing an UICommand
action. This taghandler must be placed inside an UICommand
component and the parent UIForm
must be an <o:form>
. When executing an ajax action, make sure that the parent UIForm
is also included in the <f:ajax execute>
.
Usage
For example:
<o:form>
...
<h:commandButton value="save valid data" action="#{bean.saveValidData}">
<o:ignoreValidationFailed />
<f:ajax execute="@form" />
</h:commandButton>
</o:form>
Note that the model values will (obviously) only be updated for components which have actually passed the validation. Also the validation messages will still be displayed. If you prefer to not display them, then you'd need to exclude them from rendering by <f:ajax render>
, or to put a proper condition in the rendered
attribute.
Demo
Demo source code
<o:form>
<h3>Please fill out all of those fields.</h3>
<h:panelGrid columns="3">
<o:outputLabel for="input1" value="Foo" />
<h:inputText id="input1" required="true" />
<h:message for="input1" />
<o:outputLabel for="input2" value="Bar" />
<h:inputText id="input2" required="true" />
<h:message for="input2" />
<o:outputLabel for="input3" value="Baz" />
<h:inputText id="input3" required="true" />
<h:message for="input3" />
<h:panelGroup />
<h:panelGroup>
<h:commandButton value="save">
<f:ajax execute="@form" render="@form" />
<o:ignoreValidationFailed />
</h:commandButton>
<h:commandButton value="submit">
<f:ajax execute="@form" render="@form" />
</h:commandButton>
</h:panelGroup>
<h:panelGroup>
<h:outputText value="OK!" rendered="#{facesContext.postback and not facesContext.validationFailed}" />
</h:panelGroup>
</h:panelGrid>
</o:form>
Documentation & Sources