11 Replies Latest reply on Sep 7, 2007 7:01 AM by shaun lee

    Problem with selectItems

    Hannes Schulz Newbie

      Hi,

      im trying my best to get a selectbox filled with objects. I tried the following simple example:

      @Stateless
      @Name("buildinglist")
      public class ItemListAction implements ItemList,Serializable{
      
       public List buildingList;
      
       @Factory("buildingList")
       public void listBuildings(){
       this.buildingList = new ArrayList();
       SelectItem item = new SelectItem("1", "My First Item");
       this.buildingList.add(item);
       item = new SelectItem("2","My Second Item");
       this.buildingList.add(item);
       }
      }
      


      and i try to access and display it via the followin code:

      <h:selectOneMenu>
       <f:selectItem itemLabel="" itemValue="null"/>
       <f:selectItems value="#{buildingList}"></f:selectItems>
      </h:selectOneMenu>
      


      when i request the page i get the following error;
      "Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(j_id10).


      Can someone help me please...

      regards,
      hannes

        • 1. Re: Problem with selectItems
          Pete Muir Master

          Try using s:selectItems in Seam (take a look at the ui example)

          • 2. Re: Problem with selectItems
            Hannes Schulz Newbie

            using s:selectItems leads to the same error message

            • 3. Re: Problem with selectItems
              Pete Muir Master

              Lets see some code - how you create the list, how you use it, and the stack trace. Also, what version of JSF and Seam are you using.

              • 4. Re: Problem with selectItems
                Hannes Schulz Newbie

                first thanks you for the fast answers and your help.

                the way i generate the list and the way i use it can u see in my initial post.

                the stack trace is the following:

                java.lang.IllegalArgumentException: "Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(j_id10).
                 at com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:342)
                 at com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:506)
                 at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:482)
                 at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:447)
                 at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:847)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:893)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:889)
                 at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:571)
                 at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                 at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:229)
                 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
                 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
                 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:159)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
                 at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
                 at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
                 at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
                 at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                 at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
                 at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
                 at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
                 at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
                 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                 at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
                 at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
                 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                 at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                 at java.lang.Thread.run(Thread.java:619)
                


                • 5. Re: Problem with selectItems
                  Hannes Schulz Newbie

                  and i use jsf1.2 RI with facelets

                  • 6. Re: Problem with selectItems
                    Hannes Schulz Newbie

                    ... and jboss-seam-1.2.0.PATCH1

                    • 7. Re: Problem with selectItems
                      Pete Muir Master

                      Take a look at the ui example to see how to use s:selectItems (it decouples your business and presentation logic)

                      • 8. Re: Problem with selectItems
                        Hannes Schulz Newbie

                        i looked at the examples but they do not help me. in the example they get the objects by a named query.

                        my goal is to set up a stateless ejb that serves lists to display them e.g. in the selectItems component. As soon as that works i want to retrieve the objects out of a database.

                        • 9. Re: Problem with selectItems
                          Martin Krajci Newbie

                          I had the same problem and the solution was very simple. On the bean where @Factory annotation is used the @Name must be specified. This way seam initializes the factory and doesn't return null.

                          • 10. Re: Problem with selectItems
                            shaun lee Newbie

                            try to use <s:selectItem>.

                            • 11. Re: Problem with selectItems
                              shaun lee Newbie

                              try <s:selectItem>.