How to make some button which can skip web required validation(but still I want to process all data, so immediate and so on cannot be true).
Important is that it must be universal. At the moment I am using in every required field condition with some request param. Code example below
<p:inputText value="#{cc.attrs.data.exampleData1}"
required="#{param['onlySave'] == null}"/>
<p:inputText value="#{cc.attrs.data.exampleData2}"
required="#{param['onlySave'] == null}"/>
<p:inputText value="#{cc.attrs.data.exampleData3}"
required="#{param['onlySave'] == null}"/>
<p:commandButton value="Zapisz zmiany"
action="#{cc.attrs.controller.save()}"
update="@form">
<f:param name="onlySave" value="true"/>
</p:commandButton>
This solution is fine cause I can in every page just add this param to button and it skips validation, but when my save button not making any redirect, in case of failed some java validation in save method, I am just adding some message without redirect and then I lost all required styles from inputs.
Is there any possibility to set onlySave param to null in save method when validation failed or maybe some better solutions?
Edit: Balus answer great, but with bean validation like:
@Pattern(regexp = "^([^0-9]*)$", message = "only non numbers")
String field;
It processes to bean all data beyond that field. The best would be ignore only required field property, not validation etc.
Edit2:
<tr>
<td class="label">
<p:outputLabel id="label" for="#{cc.attrs.componentId}" value="#{cc.attrs.label}"/>
</td>
<td class="value">
<cc:insertChildren/> --here component with componentId
</td>
</tr>
<tr class="errorMessage">
<td class="label"/>
<td class="value">
<p:message id="error" for="#{cc.attrs.componentId}" />
</td>
</tr>