Lenik
Lenik

Reputation: 14458

How to disable the entire bean validation in JSF?

I want to process JSR-303 validation myself, i.e., get validation factory and invoke validate method myself:

class FormBean {
    void saveForm() {
         if (! doValidate()) {
             FacesContext.addMessage(...);
             return;
         }
         ...
     }
     void doValidate() { ... }
 }

Is there any way to disable the bean validation integrated in JSF? (Not that immediate="true", which will not only bypass the validation, but also bypass update-model phases)

Upvotes: 2

Views: 7086

Answers (1)

Christoph Ehscheidt
Christoph Ehscheidt

Reputation: 148

You can disable it by disabling the validator for the fields:

<h:inputText value="#{bean.name}">
  <f:validateBean disabled="true"/>
</h:inputText>

Update: In order to disable the bean validation for every input field by default, try to set the context variable: javax.faces.validator.DISABLE_DEFAULT_BEAN_VALIDATOR with the value 'true'

Upvotes: 11

Related Questions