检查 JSF 中表单部分的验证错误
我正在构建一个 Seam 应用程序,它基本上是一个分为不同部分或模块的巨大表单。我需要一种方法来确定模块何时“完成”,这意味着该模块中字段的所有验证都通过了。然后我需要在视图中做一些事情,设置 css-class 或其他什么。
比如:
<a:region id="region1">
<s:div styleClass="#{invalid ? 'errors' : ''}">
<h:inputText required="true" id="input1" />
<h:inputText required="true" id="input2" />
<h:commandButton value="Save this section" reRender="region1" />
</s:div>
</a:region>
我想我有两个选择:
- 使用某种视图逻辑(例如单个字段的 #{invalid})
- 使用 bean 中的方法,我以编程方式获取模块的所有组件,并检查它们的验证错误。
但是,我找不到任何方法来完成其中任何一个。如果这可能的话,有什么想法吗?
我们将 JSF 1.2 与 Seam 结合使用。
谢谢。
I'm building a Seam application, which is basically a huge form divided into different parts, or modules. I need a way to figure out when a module is "complete", meaning all validation for the fields in that module passes. I then need to do something in the view, setting a css-class or whatever.
Something like:
<a:region id="region1">
<s:div styleClass="#{invalid ? 'errors' : ''}">
<h:inputText required="true" id="input1" />
<h:inputText required="true" id="input2" />
<h:commandButton value="Save this section" reRender="region1" />
</s:div>
</a:region>
I figured I had two options:
- Using some sort of view-logic (like #{invalid} for a single field)
- Using a method in the bean, where I get all components for the module programmatically, and check them for validation errors.
However, I can't find any way to do any of them. Any ideas if this is even possible?
We're using JSF 1.2 with Seam.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
UIInput #isValid()
检查特定输入组件是否发生验证错误。You can use
UIInput#isValid()
to check if a validation error has occurred on the particular input component.