Question

I'm using JSF 2.1 with RichFaces 4 and I have a form with a selectManyCheckbox which I want it to have at least one item selected before processing the form.

I put to true the attribute required but no message appears when I click the submit button without selecting at least one checkbox.

How can I do that?

Cheers

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}"/>
Was it helpful?

Solution

You need to attach a <h:message> for the <h:selectManyCheckbox>.

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

The validation message will show in there.

When using ajax to submit the form, make sure that the <h:message> component(s) are also included in the ajax render/update.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top