Seam:模态面板关闭后重置表单验证
我正在努力解决以下问题:
- 我有一个用于在 Richfaces 视图上添加新人的 modalPanel
- 我有两个按钮“保存”和“取消”
- 使用 h:inputText 组件上的 required="true" 属性时,某些输入字段是必需的
- 当我 将一个或多个必填字段留空并取消表单/模态面板,模态面板关闭
- 当我现在想要添加一个新人员时,我在支持 bean 上实例化一个新的 Person 对象,重新渲染 modalPanel 中的元素。
- ModalPanel 再次打开
- 有时会发生这种情况,我第一次尝试创建新人物时验证失败阻碍了 modalPanel 输入字段验证的重新渲染
- 我看到新人物对象中的新空字段,但视图具有验证上次尝试的错误消息?
那么,如何确保通过单击“添加人员”按钮重置所有后端逻辑、表单和按钮?
谢谢
Im struggling with the following problem:
- I have a modalPanel for adding a new person on my Richfaces view
- I have two buttons "Save" and "Cancel"
- Some input fields are required with required="true" attribute on h:inputText component
- when I leave one or more required fields empty and cancel the form/modalpanel, the modalpanel closes
- When I now want to add a new person, I instantiate a new Person object on my backing bean, reRender the elements in the modalPanel.
- ModalPanel opens up again
- Sometime it happens, that the failed validation on my first attempt to create a new person impeded the reRendering of the validation of my modalPanel input fields
- I see the new empty fields from my new person object, but the view has the validation error messages from the last attempt?
So, how can I make sure to reset all backend logic, form and buttons by clicking the "Add Person" button?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加新人时,您可以开始新对话。用
@Begin
标记该方法。这样它就会忽略之前对话中发生的一切。然后,当您按下保存按钮时,您可以使用
@End
标记该操作取消按钮可以并且应该标记为
@End(beforeRedirect=true)
(beforeRedirect=true) 是可选的,但可能会有所帮助You can start a new conversation when you add new person. Mark the method with
@Begin
. This way it will disregard everything that happened in the previous conversation.Then when you push the save button, you can mark that action with
@End
The cancel button can and should be marked with
@End(beforeRedirect=true)
(beforeRedirect=true) is optional, but can be helpful