简体   繁体   English

未提交JSF 2.0值

[英]JSF 2.0 values not being submitted

I'm struggling to get my bean to update with the new page values. 我正在努力让我的bean用新的页面值更新。 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”. 我的页面上有两个提交按钮,我根据页面处于哪种模式的布尔值来切换显示哪一个。当我的页面仅处于更新状态(未验证)时,我将显示具有即时=“ true”的提交按钮。 When the page is in process mode (validate) I show the submit button that does not have immediate=”true”. 当页面处于处理模式(验证)时,我显示的提交按钮不具有即时=“ 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. 我遇到的问题是,当我处于更新模式(未验证)时,未在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. 我只是有一个指向简单的getter / setter的值绑定。 My bean is in @ViewScope. 我的bean在@ViewScope中。

I've tried using the examples by BalusC in his excellent blogspot post: debug-jsf-lifecycle . 我已经在BalusC出色的博客文章debug-jsf-lifecycle中尝试使用了示例。 Putting immediate=”true” on the input fields has no affect when clicking on the submit button with immediate="true". 单击带有Instant =“ true”的提交按钮时,在输入字段上放置Instant =“ 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. 总而言之,据我了解,UICommand上的方法是即时=“ true”,它告诉应用程序是否跳过验证。 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 JSF 2.0.3
Tomcat 6.0.14 Tomcat 6.0.14

The immediate="true" is not intented to disable validation. Instant immediate="true"并非旨在禁用验证。 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"> . 您需要通过设置required="false"<f:validator disabled="true">来禁用验证。 Here's an example which assumes that you've a boolean process property which represents the form's state: 这是一个示例,假定您具有一个boolean process属性,该属性表示表单的状态:

<h:inputText value="#{bean.value1}" required="#{bean.process}" />
<h:inputText value="#{bean.value2}" required="#{bean.process}">
    <f:validator validatorId="someValidatorId" disabled="#{!bean.process}" />
</h:inputText>
...

This way the fields aren't required and won't be validated when process evaluates false . 这样,当process评估为false时,则不需要字段且不会对其进行验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM