开发者

How to disable the entire bean validation in JSF?

开发者 https://www.devze.com 2023-04-12 01:56 出处:网络
I want to process JSR-303 validation myself, i.e., get validation factory and invoke validate method myself:

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开发者_如何学Go not only bypass the validation, but also bypass update-model phases)


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'

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号