Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8043913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:03:59+00:00 2026-06-05T05:03:59+00:00

I have two h:selectManyCheckBox with the required attribute set to true . What I

  • 0

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

UPDATE

I’ve changed my code as follows: (just added binding and modified required)

                    <a4j:outputPanel id="todosCatalogosPEC">
                        <h:selectManyCheckbox id="selectCatalogosPEC"
                                              disabled="#{administrationBean.actualizaTodosPecChecked}"
                                              binding="selectCatalogosPEC"
                                              required="#{empty selectCatalogosSAGARPA.value}"
                                              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"
                                              binding="selectCatalogosSAGARPA"
                                              disabled="#{administrationBean.actualizaTodosSagarpaChecked}"
                                              required="#{empty selectCatalogosPEC.value}"
                                              value="#{administrationBean.catalogosSagarpaSeleccionados}"
                                              requiredMessage="Seleccione al menos un catálogo"
                                              layout="pageDirection" >
                            <f:selectItems value="#{administrationBean.catalogosSagarpaOptions}"/>
                        </h:selectManyCheckbox>
                    </a4j:outputPanel>

but got this error:

jun 01, 2012 10:31:37 AM org.apache.catalina.core.StandardWrapperValve invoke
Grave: Servlet.service() for servlet [Faces Servlet] in context with path [/SRC_RichFaces] threw exception [java.lang.String cannot be cast to javax.faces.component.UIComponent] with root cause
java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.component.UIComponent
    at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1941)
    at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1144)
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.createComponent(ComponentTagHandlerDelegateImpl.java:504)
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:157)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
    at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
    at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
    at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
    at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
    at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
    at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
    at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
    at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:774)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:04:00+00:00Added an answer on June 5, 2026 at 5:04 am

    You need to bind them both to the view and in the required attribute of the first one, check if the UIInput#getSubmittedValue() of the second one is empty and in the required attribute of the second one, check if the UIInput#getValue() of the first one is empty.

    <h:selectManyCheckbox 
        binding="#{selectCatalogosPEC}"
        required="#{empty selectCatalogosSAGARPA.submittedValue}"
    >
        ...
    </h:selectManyCheckbox>
    
    <h:selectManyCheckbox
        binding="#{selectCatalogosSAGARPA}"
        required="#{empty selectCatalogosPEC.value}"
    >
        ....
    </h:selectManyCheckbox>
    

    See also:

    • JSF two required h:inputText (exclusive or)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have two events: $('body').mouseup(function(e){} and $('.toggle').click(function(e){} I only want one of these to trigger.
Have two fields start and end, both are dates, I want to write a
I have two richtextbox's that display stored procedures and its previous version. I would
I have two NSArray objects and I want to add the two arrays together
I have two application that need to talk to each other. App1 needs to
I have two classes generated by LINQ2SQL both from the same table so they
I have two classes Order and Items I want a method like this class
I have two inputs with the same date, but i want to separate the
I have two different Classes: class X { public int TX1 { get; set;
I have two function, one function is a reload function that does a ajax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.