【问题标题】:Required message in SelectManyCheckbox componenteSelectManyCheckbox 组件中的必需消息
【发布时间】:2012-03-14 00:05:26
【问题描述】:

我将 JSF 2.1 与 RichFaces 4 结合使用,并且我有一个带有 selectManyCheckbox 的表单,我希望它在处理表单之前至少选择一个项目。

我将required 属性设置为true,但是当我单击提交按钮而不选择至少一个复选框时没有显示任何消息。

我该怎么做?

干杯

更新

                <a4j:outputPanel id="cargaDependencias">
                    <h:selectManyCheckbox layout="pageDirection" required="true" 
                                          requiredMessage="Seleccione al menos una dependencia"
                                          disabled="#{administrationBean.loadAllDependencies}"
                                          value="#{administrationBean.selectedDependencies}">
                        <f:selectItems value="#{administrationBean.loadSelectDependencies}"/>
                    </h:selectManyCheckbox>
                </a4j:outputPanel>
                <br/><br/>

                <a4j:commandButton value="Actualizar Cubo"
                                   action="#{administrationBean.doUpdateInformationCube}"/>

【问题讨论】:

  • 我建议您使用 javascript 验证复选框选择。

标签: validation jsf required selectmanycheckbox


【解决方案1】:

您需要为&lt;h:selectManyCheckbox&gt; 附加&lt;h:message&gt;

<h:selectManyCheckbox id="dependencies" ...>
    ...
</h:selectManyCheckbox>
<h:message for="dependencies" />

验证消息将显示在那里。

使用 ajax 提交表单时,请确保 &lt;h:message&gt; 组件也包含在 ajax 渲染/更新中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-30
    • 2019-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-27
    • 1970-01-01
    相关资源
    最近更新 更多