2012-03-14 43 views
0

我正在使用JSF 2.1和RichFaces 4,我有一個表格,其中selectManyCheckbox我希望它在處理表單之前至少選擇一個項目。SelectManyCheckbox組件需要的消息

我將屬性required設置爲true,但當沒有選中至少一個複選框時單擊提交按鈕時不會顯示任何消息。

我該怎麼做?

乾杯

UPDATE

   <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}"/> 
+0

我建議您使用javascript驗證複選框選擇。 – 2012-03-14 06:52:05

+0

請添加小臉代碼。 – 2012-03-14 08:51:21

回答

1

您需要附上<h:message><h:selectManyCheckbox>

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

確認消息將顯示在那裏。

使用ajax提交表單時,請確保<h:message>組件也包含在ajax呈現/更新中。

+0

是啊,謝謝!永遠幫助別人! – BRabbit27 2012-03-14 20:34:32