11 Replies Latest reply on Jun 26, 2009 6:50 PM by Ruben Jorge

    Accessing pickList's selected values

    Ruben Jorge Newbie

      Hello everyone,

      I'm trying to use a rich:pickList with two datastructures: one for the possible option values and another to retrieve the user selected values. I can create and populate the pickList with the option values, like this:

      <rich:pickList copyAllControlLabel="Add all" copyControlLabel="Add">
       <f:selectItems value="#{SessionBean.tempDistincts}"/>
      </rich:pickList>
      


      tempDistincts is:

      private ArrayList<SelectItem> tempDistincts = new ArrayList<SelectItem>();
      


      And populated this way:

      Vector<String> values = extractor.getDistinctValues();
      for (int i = 0; i < values.size(); i++) {
       tempDistincts.add(new SelectItem(values.elementAt(i)));
      }
      


      This pick list displays the values correctly, however, when I try to add a new structure to retrieve the selected values I get an error.

      The XML code is:

      <rich:pickList value="#{SessionBean.tempSelectedValues}" copyAllControlLabel="Add all" copyControlLabel="Add">
       <f:selectItems value="#{SessionBean.tempDistincts}"/>
      </rich:pickList>
      


      Where tempSelectedValues is:

      private ArrayList<String> tempSelectedValues = new ArrayList<String>();
      


      When I try to run, I get the following error:

      java.lang.NullPointerException
       at org.ajax4jsf.util.ELUtils.getGenericCollectionType(ELUtils.java:144)
       at org.ajax4jsf.util.ELUtils.getContainerClass(ELUtils.java:174)
       at org.richfaces.component.UIPickList.getConverterForValue(UIPickList.java:93)
       at org.richfaces.component.UIPickList.getConverter(UIPickList.java:72)
       at org.richfaces.renderkit.PickListRenderer.encodeRows(PickListRenderer.java:245)
       at org.richfaces.renderkit.PickListRenderer.encodeSourceRows(PickListRenderer.java:359)
       at org.richfaces.renderkit.html.PickListRendererGen.doEncodeChildren(PickListRendererGen.java:371)
       at org.richfaces.renderkit.html.PickListRendererGen.doEncodeChildren(PickListRendererGen.java:279)
       at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:826)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
       at org.richfaces.renderkit.html.ModalPanelRenderer.doEncodeChildren(ModalPanelRenderer.java:387)
       at org.richfaces.renderkit.html.ModalPanelRenderer.doEncodeChildren(ModalPanelRenderer.java:382)
       at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:826)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
       at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:826)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:220)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:215)
       at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:826)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
       at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:273)
       at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:204)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
       at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
       at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
       at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
       at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
       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:368)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
       at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
       at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
       at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
       at weblogic.security.service.SecurityManager.runAs(Unknown Source)
       at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
       at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
       at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
       at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
       at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
      


      I thought that maybe I had to use the same SelectItem type for the selected items variable, but I get the same error.

      Any ideas please?

      Thanks in advance,
      ~Ruben