5 Replies Latest reply on Dec 23, 2007 8:57 PM by valeriopp

    Problem with selectManyCheckbox and EntityConverter

    valeriopp

      Hello,

      I have: my .xhtml like:

      
      <h:selectManyCheckbox value="#{AutorizzatiFoManager.selezionati}" layout="pageDirection" >
       <si:selectItems value="#{autorizzati}" var="fornitore" label="#{fornitore.nomeFornitore} - #{fornitore.messaggio}" />
       <ec:convertEntity entityClass="org.jboss.seam.example.registration.Fornitore" />
      </h:selectManyCheckbox>
      
      


      and in the AutorizzatiFoManager class:

       @DataModel
       private List<Fornitore> autorizzati;
      
       @DataModelSelection
       @Out(required=false)
       private Fornitore tempautorizzato;
      
       @OneToMany
       @Out (required=false)
       private List<Fornitore> selezionati;
      
      


      Note that the OneToMany List selezionati is a member in the bean class AutorizzatiFoManager (not in an Entity). Is that a problem?

      my persistence.xml:
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/selectItemsEntityManagerFactory"/>
       <property name="jboss.entity.manager.jndi.name" value="java:/selectItemsEntityManager"/>
      


      my components.xml:
       <core:managed-persistence-context name="entityManager" persistence-unit-jndi-name="java:/selectItemsEntityManagerFactory"/>
      


      Now it shows the list of Fornitore but when I try to check one or more Fornitore, the error is:

      cause java.lang.NoClassDefFoundError: org/jboss/seam/core/Messages
      class class javax.servlet.ServletException
      localizedMessage Servlet execution threw an exception
      message Servlet execution threw an exception

      rootCause java.lang.NoClassDefFoundError: org/jboss/seam/core/Messages


      stackTrace [org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313), org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206), org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83), org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68), org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69), org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85), org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69), org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64), org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69), org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44), org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69), org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141), org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281), org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60), org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69), org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58), org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69), org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158), org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235), org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206), org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96), org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235), org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206), org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230), org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175), org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179), org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84), org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127), org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102), org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157), org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109), org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262), org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844), org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583), org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446), java.lang.Thread.run(Thread.java:595)]


      Any suggestions?

      thanks in advance.

      Valerio

        • 1. Re: Problem with selectManyCheckbox and EntityConverter
          valeriopp

          In alternative, there is a simple way to obtain the same result:
          the aim is to obtain a list of selected entities (cheched by a checkbox) from another list (of the same type) in a bean?

          • 2. Re: Problem with selectManyCheckbox and EntityConverter
            pmuir

            What version of Seam? You should use either 1.2.1 or 2.0.0 where both s:selectItems and s:convertEntity are built into Seam.

            • 3. Re: Problem with selectManyCheckbox and EntityConverter
              valeriopp

              I use Seam 2.0.0 . Then I changed to:

               <h:selectManyCheckbox value="#{selezione.fornitoriSelezionati}" layout="pageDirection" >
               <s:selectItems value="#{AutorizzatiFoManager.autorizzati}" var="fornitore" label="#{fornitore.nomeFornitore} - #{fornitore.messaggio}" />
               <s:convertEntity entityClass="org.jboss.seam.example.registration.Fornitore"/>
               </h:selectManyCheckbox>
              


              components.xml
              <persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/epEntityManagerFactory" />
              


              Persistence.xml
               <property name="jboss.entity.manager.factory.jndi.name"
               value="java:/epEntityManagerFactory" />



              in Selezione.java (the entity class named selezione in the context)
              @OneToMany
               private List<Fornitore> fornitoriSelezionati;
              


              in AutorizzatiFoManager.java
               private List<Fornitore> autorizzati;
              


              I still get the right list, but when i check one or more checkbox, i get a facesmessage:
              j_id96:j_id101: Validation Error: Value is not valid

              the html generated code for the SelectManycheckbox is, for example for the third element of the list:
              <input name="j_id96:j_id101" id="j_id96:j_id101:3" value="3" type="checkbox" checked="checked" /><label for="j_id96:j_id101:3">Third element ....</label>
              

              while before in the value field I had theClassPackage.Fornitore(a)[a coded id]

              • 4. Re: Problem with selectManyCheckbox and EntityConverter
                pmuir

                 

                I still get the right list, but when i check one or more checkbox, i get a facesmessage:
                j_id96:j_id101: Validation Error: Value is not valid


                http://wiki.jboss.org/wiki/Wiki.jsp?page=SeamProblemsFAQ

                • 5. Re: Problem with selectManyCheckbox and EntityConverter
                  valeriopp

                  I set up a long running conversation as suggested in the FAQ.
                  But I don't understand: still having the same validation error.

                  I verified (running debug.seam) that, in the Conversation Context, I have:
                  AutorizzatiFoManager.autorizzati (the original element list)
                  and
                  AutorizzatiFoManager.selezionati (the list of selected items)

                  in autorizzati I have, for example, this list:
                  0 org.jboss.seam.example.registration.Fornitore@dddee8
                  1 org.jboss.seam.example.registration.Fornitore@556e82
                  2 org.jboss.seam.example.registration.Fornitore@ca5165
                  3 org.jboss.seam.example.registration.Fornitore@a5d3d5

                  I verified that autorizzati remains the same after calling the bean methods and re-calling the page or posting the item selection.
                  (I mean that also the object id (the xxxxx id in ....Fornitore@xxxxx) remains the same, while it didn't happen when the scope of AutorizzatiFoManager was not the conversation) so the original list do NOT change now.

                  I tried to assign selezionati=autorizzati just in the Factory method of AutorizzatiFoManager. So when i call the page I correctly see that all checkboxes are checked, since all elements of original list autorizzati is in the selected list selezionati(so the 'output' of selezionati works). But if I confirm (checking at least one item), then I get the validation error (if I check none it works correctly, since the selectedItems value is null and isn't converted, I suppose).

                  Maybe I made a mistake in .xml files (I posted in this thread) ? Is it possible to verify that the converter is correctly called? how can I find the values that are trying to be assigned to selezionati but are not validated?

                  Thanks for your help.
                  Valerio