jsf - Universally skip validation params on required inputs -


how make button can skip web required validation(but still want process data, immediate , on cannot true).

important must universal. @ moment using in every required field condition 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 fine cause can in every page add param button , skips validation, when save button not making redirect, in case of failed java validation in save method, adding message without redirect , lost required styles inputs.

is there possibility set onlysave param null in save method when validation failed or maybe better solutions?

edit: balus answer great, bean validation like:

@pattern(regexp = "^([^0-9]*)$", message = "only non numbers") string field; 

it processes bean data beyond field. best ignore 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 componentid     </td> </tr> <tr class="errormessage">     <td class="label"/>     <td class="value">         <p:message id="error" for="#{cc.attrs.componentid}" />     </td> </tr> 

please see below modified code required fields. can use #{empty param.onlysave} fields want skip validation , per requirements.

<p:inputtext value="#{cc.attrs.data.exampledata1}"               required="#{not empty param.onlysave}"/> <p:inputtext value="#{cc.attrs.data.exampledata2}"               required="#{not empty param.onlysave}"/> <p:inputtext value="#{cc.attrs.data.exampledata3}"               required="#{not empty param.onlysave}"/>  <p:commandbutton value="zapisz zmiany"                  action="#{cc.attrs.controller.save()}"                  update="@form">    <f:param name="onlysave" value="true"/> </p:commandbutton> 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -