4 Replies Latest reply on Jun 30, 2008 3:12 PM by nimo stephan

    s:convertEntity Setup with selectManyCheckbox

    nimo stephan Master

      I wanna use a selectManyCheckbox..


      <h:selectManyCheckbox value="#{entityBean.choices}">
      <s:selectItems value="#{selectableList}" var="s" label="#{s.id}"/>
      <s:convertEntity/>
      </h:selectManyCheckbox>
      



      How do I use the convertEntity-Tag? I have the problem, that when the User clicks SAVE the Error


      EntityManager is closed



      occurs. I also configured it in components.xml:


      <component name="org.jboss.seam.ui.EntityConverter">
      <property name="session">#{hibernateSession}</property>
      </component>



      Have I anything missed ?


      How can I 'open' the EntityManager while transaction?


      Is there an example of an selectManyCheckbox with SEAM.




        • 1. Re: s:convertEntity Setup with selectManyCheckbox
          nimo stephan Master

          I use also a Seam managed transaction..


          Before I tried to use this:


          <h:selectManyCheckbox value="#{entityBean.choices}">
          <s:selectItems value="#{selectableList}" var="s" label="#{s.description}" itemValue="#{s.id}"/>
          </h:selectManyCheckbox>
          



          but I refer to an entityBean and its property 'choices' is declared as follows


           private Set<Choices> choices = new HashSet<Choices>();
          



          So u see its a relationship to the EntityBean 'Choices'. So when I use the converEntity it should be cast to selectItems and give the selected Items as a Set..but this does not work. Why? How can I solve that?

          • 2. Re: s:convertEntity Setup with selectManyCheckbox
            nimo stephan Master

            Have forgot to say that:


            When I use s:selectItems with s:convertEntity:


            <s:selectItems value="#{selectableList}" var="s" label="#{s.description}" itemValue="#{s.id}"/>
            <s:convertEntity/>
            



            then the Error:



            Not an entity class: java.lang.Integer



            occurs.


            The itemValue s.id is indeed a java.lang.Integer in my entityBean which I obtain from the list selectableList:


            @Factory("selectableList")
            public List <SelectItem> getSelectableList() {
            
            return entityManager.createQuery("from EntityBean s").getResultList();  }
            





            • 3. Re: s:convertEntity Setup with selectManyCheckbox
              nimo stephan Master

              upss I use the latest SEAM 2.1 build and I cannot (must not) configure the entityConverter in applications.xml. However, the failures is the same..'EntityManager closed':-(

              • 4. Re: s:convertEntity Setup with selectManyCheckbox
                nimo stephan Master

                I want to use s:convertEntity and my setup is right. I set it up in components.xml:



                     <component name="org.jboss.seam.ui.EntityConverter">
                       <property name="entityManager">#{entityManager}</property>
                     </component>



                and injected it with entityManager.


                But I get the following problem:



                13:06:17,418 ERROR [[/mySeamProject]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
                java.lang.RuntimeException: Could not create Component: org.jboss.seam.ui.EntityConverter
                     at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1032)
                     at org.jboss.seam.init.Initialization.installComponents(Initialization.java:948)
                     at org.jboss.seam.init.Initialization.init(Initialization.java:623)
                     at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
                     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
                     at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
                     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
                     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
                     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
                     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                     at java.lang.reflect.Method.invoke(Unknown Source)
                     at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
                     at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                     at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
                     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                     at java.lang.reflect.Method.invoke(Unknown Source)
                     at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
                     at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                     at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
                     at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
                     at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
                     at org.jboss.web.WebModule.startModule(WebModule.java:83)
                     at org.jboss.web.WebModule.startService(WebModule.java:61)
                     at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                     at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                     at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                     at java.lang.reflect.Method.invoke(Unknown Source)
                     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                     at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                     at $Proxy0.start(Unknown Source)
                     at org.jboss.system.ServiceController.start(ServiceController.java:417)
                     at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                     at java.lang.reflect.Method.invoke(Unknown Source)
                     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                     at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                     at $Proxy44.start(Unknown Source)
                     at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)



                any ideas?