Set required attribute of two h:selectManyCheckbox
Posted
by
BRabbit27
on Stack Overflow
See other posts from Stack Overflow
or by BRabbit27
Published on 2012-05-31T22:37:27Z
Indexed on
2012/05/31
22:41 UTC
Read the original article
Hit count: 171
I have two h:selectManyCheckBox
with the required attribute set to true.
What I want is that the required attribute of both of the components work together.
Only display the error message if and only if both of the selected items list are empty.
Right now my problem is that the message displays if either one of them is empty. Here's my code:
<rich:panel>
<f:facet name="header">
<h:outputText value="Actualización de catálogos"/>
</f:facet>
<h:panelGrid columns="4">
<h:outputLabel for="actualizarCatalogoPEC"
value="Actualizar catálogos PEC"/>
<h:selectBooleanCheckbox id="actualizarCatalogoPEC"
value="#{administrationBean.actualizaTodosPecChecked}">
<f:ajax event="click"
render="todosCatalogosPEC"/>
</h:selectBooleanCheckbox>
<h:outputLabel for="actualizarCatalogoSAGARPA"
value="Actualizar catálogos SAGARPA"/>
<h:selectBooleanCheckbox id="actualizarCatalogoSAGARPA"
value="#{administrationBean.actualizaTodosSagarpaChecked}">
<f:ajax event="click"
render="todosCatalogosSAGARPA"/>
</h:selectBooleanCheckbox>
<a4j:outputPanel id="todosCatalogosPEC">
<h:selectManyCheckbox id="selectCatalogosPEC"
disabled="#{administrationBean.actualizaTodosPecChecked}"
required="true"
value="#{administrationBean.catalogosPecSeleccionados}"
requiredMessage="Seleccione al menos un catálogo"
layout="pageDirection">
<f:selectItems value="#{administrationBean.catalogosPecOptions}"/>
</h:selectManyCheckbox>
</a4j:outputPanel>
<h:panelGroup/>
<a4j:outputPanel id="todosCatalogosSAGARPA">
<h:selectManyCheckbox id="selectCatalogosSAGARPA"
disabled="#{administrationBean.actualizaTodosSagarpaChecked}"
required="true"
value="#{administrationBean.catalogosSagarpaSeleccionados}"
requiredMessage="Seleccione al menos un catálogo"
layout="pageDirection" >
<f:selectItems value="#{administrationBean.catalogosSagarpaOptions}"/>
</h:selectManyCheckbox>
</a4j:outputPanel>
<h:panelGroup/>
<rich:message id="messageCatalogosPEC"
for="selectCatalogosPEC"/>
<h:panelGroup/>
<rich:message id="messageCatalogosSAGARPA"
for="selectCatalogosSAGARPA"/>
<h:panelGroup/>
<a4j:commandButton value="Actualizar catálogos"
render="messageCatalogosPEC"
action="#{administrationBean.doActualizaCatalogos}"/>
</h:panelGrid>
</rich:panel>
Cheers
© Stack Overflow or respective owner