6 Replies Latest reply on Jul 15, 2009 5:15 AM by Nick Belaevski

    problem with SelectOneMenu and SelectItem

    praveen jain Novice

      hi
      i am initializing the <h:selectOneMenu> using beans my code is
      i want to assign a Object as value in the list so that i can get entire object which is selected , but i am getting exception , will u pls tell me how to get objects from the list.

      <h:selectOneMenu value="#{cars.selmnu}">
       <f:selectItems value="#{cars.mnu}" />
       </h:selectOneMenu>
      

      my beans class has
       ArrayList<SelectItem> mnu=new ArrayList<SelectItem>();
       Menu selmnu=new Menu();
      
       public Menu getSelmnu() {
       return selmnu;
       }
      
       public void setSelmnu(Menu selmnu) {
       this.selmnu = selmnu;
       }
      
       public ArrayList<SelectItem> getMnu() {
       Menu mn=new Menu();
       mnu.add(new SelectItem(mn,mn.getName()));
       return mnu;
       }
      
       public void setMnu(ArrayList<SelectItem> mnu) {
       this.mnu = mnu;
       }
      

      Menu is class is simple class contains a string variable name.

      i am using SelectItem but i am getting exception


      javax.faces.FacesException: Exception while calling encodeEnd on component : {Component-Path : [Class: org.ajax4jsf.component.AjaxViewRoot,ViewId: /successpage.jsp][Class: javax.faces.component.html.HtmlForm,Id: panelform][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: j_id_jsp_1925778943_128]}
      at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:627)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:261)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
      at org.apache.myfaces.application.jsp.JspViewHandlerImpl.actuallyRenderView(JspViewHandlerImpl.java:427)
      at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:383)
      at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
      at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
      at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
      at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:155)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:301)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.IllegalArgumentException: Value is no String (class=one.Menu, value=one.Menu@1fbfbf9) and component panelform:j_id_jsp_1925778943_128with path: {Component-Path : [Class: org.ajax4jsf.component.AjaxViewRoot,ViewId: /successpage.jsp][Class: javax.faces.component.html.HtmlForm,Id: panelform][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: j_id_jsp_1925778943_128]} does not have a Converter
      at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedStringValue(RendererUtils.java:622)
      at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet(HtmlRendererUtils.java:362)
      at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:337)
      at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.renderMenu(HtmlRendererUtils.java:288)
      at org.apache.myfaces.shared_impl.renderkit.html.HtmlMenuRendererBase.encodeEnd(HtmlMenuRendererBase.java:57)
      at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:624)
      ... 31 more