开发者

JSF immediate=true to Skip Validation

Shouldn't the immediate="true" of the commandLink skip validation? I'm still getting the "password is Required" message when I click that link, any ideas?

<h:inputSecret id="j_password" autocomplete="off" value="#{authenticationBean.password}" required="true" requiredMessage="Password is Required" />

<p:commandLink action="#{authentication.forgotPassword}" ajax="false">
    <h:outputText value="#{bundle['login.forgotpassword.TEXT']}" immediate="true"/开发者_JAVA百科>
</p:commandLink>


You've put it on the <h:outputText> instead of the <p:commandLink>. The immediate attribute has no effect on UIOutput components (and would yield a XML validation error on some environments as well), it has effect on UIInput and UICommand components only. Move the attribute to the <p:commandLink> component.


The immediate attribute does not skip any validation. It moves the component and all its events, validators etc to the APPLY_REQUEST Phase. So that you have an opportunity to process inputs and commands before all other non-immediate inputs and commands.

http://www.javacodegeeks.com/2012/01/jsf-and-immediate-attribute-command.html

If you want to skip validation with immediate, you will have to take an appropriate action in the event of the immediate action to avoid further processing of inputs and theirs events, like a FacesContext Redirect.


The <o:validateBean> allows the developer to control bean validation on a per-UICommand or UIInput component basis, as well as validating a given bean at the class level.

The standard only allows validation control on a per-form or a per-request basis (by using multiple tags and conditional EL expressions in its attributes) which may end up in boilerplate code. The standard also, despite its name, does not actually have any facilities to validate a bean at all.

<o:validateBean disabled="true"/> that command will skip Validations

<p:commandButton 
            id="refresh"
            icon="fa fa-refresh"
            styleClass="refresh-button btn-blue"
            process="@form"
            update="phone_1 @form:htmlView">
   <o:validateBean disabled="true"/>
</p:commandButton>

OR

The <o:skipValidators> taghandler allows the developer to entirely skip validation when executing an UICommand or ClientBehaviorHolder action. This taghandler must be placed inside an UICommand or ClientBehaviorHolder component (client behavior holder components are those components supporting <f:ajax>).

<p:commandButton 
      id="refresh"
      icon="fa fa-refresh"
      styleClass="refresh-button btn-blue"
      process="@form"
      update="phone_1 @form:htmlView">
   <o:skipValidators/>
</p:commandButton>

If you want to know more just look here :

http://showcase.omnifaces.org/validators/validateBean http://showcase.omnifaces.org/taghandlers/skipValidators

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜