JSF立即= true跳过验证
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
允许开发人员在每个 UICommand 或 UIInput 组件的基础上控制 Bean 验证,以及在类级别验证给定的 Bean。该标准仅允许基于每个表单或每个请求进行验证控制(通过在其属性中使用多个标签和条件 EL 表达式),这可能最终会出现在样板代码中。
该标准尽管有其名称,但实际上根本没有任何工具来验证 Bean。
该命令将跳过验证或
标记处理程序允许开发人员在执行时完全跳过验证UICommand 或 ClientBehaviorHolder 操作。该标记处理程序必须放置在 UICommand 或 ClientBehaviorHolder 组件内(客户端行为持有者组件是支持
的组件)。如果您想了解更多信息,请查看此处:
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 ValidationsOR
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>
).If you want to know more just look here :
http://showcase.omnifaces.org/validators/validateBean
http://showcase.omnifaces.org/taghandlers/skipValidators
您已将其放在
而不是
上。immediate
属性对UIOutput
组件没有影响(并且在某些环境下也会产生 XML 验证错误),它对UIInput
有影响仅限UICommand
组件。将属性移至
组件。You've put it on the
<h:outputText>
instead of the<p:commandLink>
. Theimmediate
attribute has no effect onUIOutput
components (and would yield a XML validation error on some environments as well), it has effect onUIInput
andUICommand
components only. Move the attribute to the<p:commandLink>
component.立即属性不会跳过任何验证。它将组件及其所有事件、验证器等移至 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.