在 ICEfaces 1.8.2 中实现重置按钮时遇到问题
我有一个表单,其中的值是从数据库填充的。该表单由许多ice:inputText 组件组成,其partialSubmit="true",因此当字段失去焦点时将对其进行验证。该表格有一个保存和一个重置按钮。重置按钮具有immediate=“true”,并且只是一个常规的ice:commandButton,即,而不是type=“reset”。
典型的 inputText 字段:
<ice:inputText id="input1" maxlength="6" size="6" value="#{client.inboxThreshold}" partialSubmit="true">
<f:convertNumber integerOnly="true" />
<f:validateLongRange minimum="0" />
</ice:inputText>
“重置”按钮:
<ice:commandButton value="Reset" style="margin-left:5px;" actionListener="#{client.reset}" immediate="true"/>
问题是这样的:当用户更改值并单击重置按钮时,将触发更新支持 bean 值的 actionListener。验证错误已被删除,但是,呈现页面时模型值不会更新。
阶段监听器指示它从Apply_Request_Values 到Render_Response。所以,我想我需要手动触发Update_model_values阶段。
有想法吗?
I have a form with values populated from a database. The form consists of a number of ice:inputText components with partialSubmit="true", so the fields will be validated when they lose focus. The form has a save and a reset button. The reset button has immediate="true" and is just a regular ice:commandButton, i.e., not a type="reset".
Typical inputText field:
<ice:inputText id="input1" maxlength="6" size="6" value="#{client.inboxThreshold}" partialSubmit="true">
<f:convertNumber integerOnly="true" />
<f:validateLongRange minimum="0" />
</ice:inputText>
"Reset" button:
<ice:commandButton value="Reset" style="margin-left:5px;" actionListener="#{client.reset}" immediate="true"/>
The problem is this: When a user changes the values and clicks the reset button, the actionListener is fired which updates the backing bean values. The validation errors are removed, however, the model values don't get updated when the page is rendered.
The phase listener indicates it's going from Apply_Request_Values to Render_Response. So, I think I need to manually trigger the Update_model_values phase.
Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有尝试过,但这听起来像是一个典型的相位问题。简而言之,这意味着在 actionListener 中您在太早的阶段设置了 bean 值。它们将被 jsf 组件的 SubmitedValue 覆盖。有两种可能的解决方案。
首先是绑定组件,并通过 setSubscribedValue 直接在组件中设置所需的值。
更好的解决方案是第二个。您使用标签
ice:setEventPhase
(请参阅 taglib )。这样您就可以强制在稍后阶段调用 actionListener,这样 jsf 组件上提交的值就不会覆盖 bean 上的值。因此,请尝试用
包围ice:commandButton
。附:
这来自
immediate="true"
。这样,ICEfaces 在第二阶段 (Apply_Request_Values) 中为组件(在您的例子中为commandButton
)执行所有阶段,然后针对其他组件直接进入最后一个阶段 (Render_Response)。因此,其他组件的验证器不会被调用。我建议阅读有关这些阶段的信息(例如此处,您还可以在其中找到有关以下内容的详细信息:立即在“立即事件处理”部分中)
I didn't try it but it sounds like a typically phase problem. Iin short this means in the actionListener you set the bean values in a phase which is too early. They will be overriden by the submitedValue of the jsf component. There are two possible solutions.
First is to bind the component and set the desired value directly in the component via setSubmittedValue.
The nicer solution is the second one. You use the tag
ice:setEventPhase
(see taglib). With that you can force that the actionListener is called in a later phase, thus the value on the bean is not overriden by the submitted value on the jsf component.So try to surround the
ice:commandButton
with<ice:setEventPhase phase="INVOKE_APPLICATION">
.PS:
This comes from
immediate="true"
. With that, ICEfaces does all phases for the component (in your case thecommandButton
) in the second phase (Apply_Request_Values) and goes then for the other components directly to the last phase (Render_Response). Thus the validators of the other components are not called.I recommend reading about the phases (for example here where you also find details about immediate in section "Immediate event handling")
这是因为组件将显示提交的值,而不是您的数据,请参阅 http://wiki。 apache.org/myfaces/ClearInputComponents 获取解决方案。
It is because the components will display the submitted values, not the data from your been, see http://wiki.apache.org/myfaces/ClearInputComponents for solutions.