JSF立即= true跳过验证

发布于 2024-10-28 21:21:01 字数 460 浏览 1 评论 0原文

commandLink 的 immediate="true" 不应该跳过验证吗?当我单击该链接时,我仍然收到“需要密码”消息,有什么想法吗?

<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"/>
</p:commandLink>

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"/>
</p:commandLink>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我的痛♀有谁懂 2024-11-04 21:21:02

允许开发人员在每个 UICommand 或 UIInput 组件的基础上控制 Bean 验证,以及在类级别验证给定的 Bean。

该标准仅允许基于每个表单或每个请求进行验证控制(通过在其属性中使用多个标签和条件 EL 表达式),这可能最终会出现在样板代码中。
该标准尽管有其名称,但实际上根本没有任何工具来验证 Bean。

该命令将跳过验证

<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>

标记处理程序允许开发人员在执行时完全跳过验证UICommand 或 ClientBehaviorHolder 操作。该标记处理程序必须放置在 UICommand 或 ClientBehaviorHolder 组件内(客户端行为持有者组件是支持 的组件)。

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

如果您想了解更多信息,请查看此处:

http://showcase.omnifaces.org/validators/validateBean< /a>
http://showcase.omnifaces.org/taghandlers/skipValidators

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

素罗衫 2024-11-04 21:21:01

您已将其放在 而不是 上。 immediate 属性对 UIOutput 组件没有影响(并且在某些环境下也会产生 XML 验证错误),它对 UIInput 有影响仅限 UICommand 组件。将属性移至 组件。

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.

太阳哥哥 2024-11-04 21:21:01

立即属性不会跳过任何验证。它将组件及其所有事件、验证器等移至 APPLY_REQUEST 阶段。这样您就有机会在所有其他非立即输入和命令之前处理输入和命令。

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

如果您想跳过立即验证,则必须在立即操作的情况下采取适当的操作,以避免进一步处理输入及其事件,就像 FacesContext 重定向一样。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文