0

我有一个包含 3 个字段的表单(简化示例)。

第一个是复选框。

<ice:selectBooleanCheckBox value="#{backingBean.bean.visible}" ID="checkbox1" partialSubmit="true" >

第二个是一个

<ice:inputText ID="text1">

第三个也是一个

<ice:inputText ID="text2" required="true" validator="mycustomvalidator">

text1 应该仅在选中 checkbox1 时可见。text2 是必填字段,并设置了 customvalidator。

因此,我第一种仅使用 #{backingBean.bean.visible} 的方法失败了,因为 text2 has 是必需的,并且当 text2 字段为空时(单击复选框后)会出现验证消息。由于验证错误,表单从未完全提交,因此设置了可见属性(从未达到更新模型阶段)。

我还尝试对 selectBooleanCheckBox 使用 immediate="true" ,但这只会导致 required="true" 的验证消息消失但 mycustomvalidator 的验证仍然触发。

所以我的问题是:如何确保 text1 仅在单击 checkbox1 时可见?谢谢。

4

1 回答 1

0

To give an answer here, I think the best solution is to use client side Javascript for hiding/showing the elements.

于 2010-04-01T08:40:35.617 回答