Primefaces – Skip bean validation in a datatable


We want to bypass the validations in a datatable according to the button we press


We are using Primefaces and we have a table with existing lines associated to my persisted entity that may be removed from that entity and, at the bottom of that table, there is a new line that may be added to the entity. When clicking the remove option, the last line’s validations should be bypassed. When clicking the add option, however, all validations associated to the last line should be checked.

How to

<f:validateBean disabled="#{!empty param['disableValidation']}">
  <h:inputText ... /> <h:selectOne .... /> all fields that should or shouldn't be validated

or, for a single field:

<h:inputText ...>
  <f:validateBean disabled="#{!empty param['disableValidation']}" />

and finally, pass the appropriate parameter option within the command button:

<p:commandButton action="#{bean.action}" value="click me">
  <f:param name="disableValidation" value="true" />           

Additionally, it is possible also to specify the expression language so that the field may be or not required as appropriately set from the command button:

 <p:inputText required="#{empty param['disableValidation']}" />


This recipe, taken from Primefaces forum shows a simple yet effective way to achieve our goal of validations within a table


One comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s