在 ICEfaces 1.8.2 中实现重置按钮时遇到问题

发布于 2024-10-21 06:33:43 字数 807 浏览 1 评论 0原文

我有一个表单,其中的值是从数据库填充的。该表单由许多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 技术交流群。

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

发布评论

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

评论(2

如痴如狂 2024-10-28 06:33:43

我没有尝试过,但这听起来像是一个典型的相位问题。简而言之,这意味着在 actionListener 中您在太早的阶段设置了 bean 值。它们将被 jsf 组件的 SubmitedValue 覆盖。有两种可能的解决方案。

首先是绑定组件,并通过 setSubscribedValue 直接在组件中设置所需的值。

更好的解决方案是第二个。您使用标签 ice:setEventPhase (请参阅 taglib )。这样您就可以强制在稍后阶段调用 actionListener,这样 jsf 组件上提交的值就不会覆盖 bean 上的值。

因此,请尝试用 包围 ice:commandButton

附:

阶段侦听器表明它是
从Apply_Request_Values 到
渲染_响应。所以,我想我需要
手动触发
Update_model_values 阶段。

这来自 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:

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.

This comes from immediate="true". With that, ICEfaces does all phases for the component (in your case the commandButton) 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")

牵强ㄟ 2024-10-28 06:33:43

这是因为组件将显示提交的值,而不是您的数据,请参阅 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.

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