0 Replies Latest reply on Dec 27, 2009 4:41 PM by Pavel Nikonenko

    Multiple Selection in rich:tree

    Pavel Nikonenko Newbie

      Hi everyone!

      In my application I need to have ability for multiple selection in rich tree.

      I found this article

      http://technology.amis.nl/blog/4710/multi-select-in-richfaces-trees

       

      I tried to do this but nothing works. My tree has client switch type.


      When my jsp looks like this:

       

           <f:view>
           <h:form>
                <rich:panel header="RichFaces Tree Test" style="width: 600px">
                     <rich:tree style="width:300px"
                          nodeSelectListener="#{simpleTreeBean.processSelection}"
                          reRender="selectedNode" ajaxSubmitSelection="true"
                          switchType="client" value="#{simpleTreeBean.treeNode}" var="item"
                          ajaxKeys="#{null}">
                          <rich:treeNode id="node" nodeClass="#{item.selected?'dr-tree-i-sel':''}">
                              <h:outputText value="#{item.nodeTitle}"/>
                          </rich:treeNode>
                     </rich:tree>
      
                </rich:panel>
                <h:outputText escape="false" value="Selected Node: #{simpleTreeBean.nodeTitle}" id="selectedNode" />
           </h:form>
           </f:view>
      

       

      miltiselection doesn't work at all.

      But if I add node to tree reRenderer

      reRender="selectedNode, node"

      Then I get error during node selection:

       

      description The server encountered an internal error () that prevented it from fulfilling this request.

      exception

      javax.servlet.ServletException: No tree element available or row key not set!
           javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
           org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

      root cause

      java.lang.IllegalStateException: No tree element available or row key not set!
           org.richfaces.model.TreeDataModel.isLeaf(TreeDataModel.java:301)
           org.richfaces.component.UITree.isLeaf(UITree.java:534)
           org.richfaces.renderkit.NodeRendererBase.initializeLines(NodeRendererBase.java:155)
           org.richfaces.renderkit.html.TreeNodeRenderer.doEncodeBegin(TreeNodeRenderer.java:121)
           org.richfaces.renderkit.html.TreeNodeRenderer.doEncodeBegin(TreeNodeRenderer.java:106)
           org.ajax4jsf.renderkit.RendererBase.encodeBegin(RendererBase.java:101)
           javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
           org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:280)
           org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:124)
           org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
           org.richfaces.renderkit.TreeRendererBase.encodeAjaxChildren(TreeRendererBase.java:389)
           org.ajax4jsf.component.UIDataAdaptor.encodeAjaxChild(UIDataAdaptor.java:454)
           org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:104)
           org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
           org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
           org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
           org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
           org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
           org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
           org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
           org.ajax4jsf.component.AjaxViewRoot.encodeAjax(AjaxViewRoot.java:677)
           org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:548)
           javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
           com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:266)
           com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:197)
           org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
           org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
           com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
           com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
           com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
           javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
           org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

       

      but after page refresh clicked nodes are selected.

       

      Can you help to solve my problem?