JSF 2.0 值未提交
我正在努力让我的 bean 使用新的页面值进行更新。我的页面上有两个提交按钮,我根据页面所处模式的布尔值来切换显示哪个按钮。当我的页面仅更新(无验证)时,我会显示立即=“true”的提交按钮。当页面处于处理模式(验证)时,我显示没有立即=“true”的提交按钮。 我遇到的问题是当我处于更新模式(无验证)时,输入字段中的值未在 bean 中设置。在这种模式下我想做的就是按原样保存页面并退出。不需要验证,因为该页面上的信息尚未准备好处理或“真正使用”(如果您愿意的话)。也就是说,如果我的页面处于处理模式(验证),那么一切都会按预期进行。值已提交并保存。
我还没有发布任何代码,因为我想做的事情没有什么特别的。我只是有一个指向简单 getter/setter 的值绑定。我的 bean 在 @ViewScope 中。
我尝试使用 BalusC 在他出色的 blogspot 帖子中提供的示例: 调试-jsf-lifecycle。 在输入字段上放置immediate=”true”在单击带有immediate=”true”的提交按钮时没有任何影响。总而言之,我理解 UICommand 上的 instant=”true” 是告诉应用程序是否跳过验证的方式。将其放在输入字段中只会使验证更快发生。我错过了什么吗?
有什么想法吗?非常感谢任何和所有对此的帮助!
应用程序细节:
JSF 2.0.3
雄猫6.0.14
I’m struggling to get my bean to update with the new page values. I have two submit buttons on my page and I toggle which one displays based on a Boolean value for what mode my page is in. When my page is in update only (no validation) I show the submit button that has immediate=”true”. When the page is in process mode (validate) I show the submit button that does not have immediate=”true”.
The problem I’m running into is when I am in update mode (no validation) the values in the input fields are not being set in the bean. All I want to do when in this mode is save the page as is and exit. No validation is needed because the information on that page is not ready to process or “really use” if you will. That said, if I have my page in process mode (validate) then everything works as intended. Values are submitted and saved.
I’m not posting any code yet as there is nothing special about what I’m trying to do. I simply have a value binding that points to simple getter / setter. My bean is in @ViewScope.
I’ve tried using the examples by BalusC in his excellent blogspot post: debug-jsf-lifecycle.
Putting immediate=”true” on the input fields has no affect when clicking on the submit button with immediate="true". All and all though, the way I understand it is immediate=”true” on the UICommand is what tells the application to skip validation or not. Putting it on the input fields simply makes validation happen sooner. Am I missing something?
Any ideas? Any and all help with this is most appreciated!
App specifics:
JSF 2.0.3
Tomcat 6.0.14
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
immediate="true"
无意禁用验证。其目的是优先考虑验证或完全跳过输入处理。另请参阅文章底部的摘要。您需要通过设置
required="false"
或
来禁用验证。下面是一个示例,假设您有一个表示表单状态的boolean process
属性:这样,这些字段就不是必需的,并且在
process
求值时不会进行验证假
。The
immediate="true"
is not intented to disable validation. It's intented to either prioritize validation or to skip processing of the input altogether. See also the summary at the bottom of the article.You need to disable validation by setting
required="false"
, or<f:validator disabled="true">
. Here's an example which assumes that you've aboolean process
property which represents the form's state:This way the fields aren't required and won't be validated when
process
evaluatesfalse
.