JSF 2.0 验证错误导致输入字段显示本地值而不是更新的模型值

发布于 2024-12-17 06:30:52 字数 248 浏览 0 评论 0原文

该应用程序使用JSF 2.0框架。 用户将值输入到表单中。当用户选择保存时,某些字段存在验证错误,有些则没有。 用户单击取消按钮。然后用户再次单击更新按钮。 即使模态值已更新,选择保存时具有有效值的字段也会显示本地值而不是更新后的模型值。

我通过在取消的操作方法中添加一个resetValues()方法解决了这个问题。 resetValues() 循环遍历子级列表并将本地值重置为 null。

对于这个问题有没有更好的解决方案来提高应用程序的性能呢?

The application uses JSF 2.0 framework.
User inputs values to a form. When user selects save, some fields have validation errors and some don't.
User clicks on cancel button. Then user clicks the update button again.
Even though the modal values are updated, the fields which had valid values when save was selected display the local values instead of the updated model values.

I solved this issue by adding a resetValues() method in the action method of cancel.
The resetValues() loops through the list of children and reset the local values to null.

Is there a better solution for this problem to improve the performance of the application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

葬﹪忆之殇 2024-12-24 06:30:52

取消按钮应该重新创建视图。您可以通过将导航结果返回到同一视图来实现此目的,如有必要,可以使用faces-redirect=true。

The cancel button should recreate the view. You can do it by returning a navigation outcome to the same view, if necessary with faces-redirect=true.

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