3 Replies Latest reply on Dec 12, 2012 7:33 AM by Dinesh Lomte

    richtree not expanding with special symbols like (&,>)

    ravindra ravuri Newbie

      I have problem in <rich:tree> expansion,

      If any of the parent node contains

      special symbols like (&,>) then the tree expansion is not working....please help me out in solving this problem

       

      how to use rowKeyConverter:

       

      If the <rich:tree> component uses a custom data model, the data model provides unique keys for tree nodes so they can be identified during a client request. The <rich:tree> component can use strings as key values. These strings may contain special characters that are not allowed by browsers, such as the left angle bracket (<) and ampersand (&). To allow these characters in the keys, a row key converter must be provided.

      To apply a converter to the <rich:tree> component, define it with the rowKeyConverter attribute.

        • 1. Re: richtree not expanding with special symbols like (&,>)
          Jan Papousek Newbie

          Hi,

           

          I've tried to reproduce described behaviour, but I haven't been successful. The following code works as expected:

           

          public class Node {
          
              private List<Node> children;
              private String label;
          
              public Node(String label, List<Node> children) {
                  this.label = label;
                  this.children = children;
              }
          
              public synchronized List<Node> getChildren() {
                  if (children == null) {
                      children = new ArrayList<Node>();
                  }
                  return children;
              }
          
              public String getLabel() {
                  return label;
              }
          
          }
          

           

           

          @ViewScoped
          @ManagedBean
          public class TestBean implements Serializable {
          
              private List<Node> roots;
          
              @PostConstruct
              public void init() {
                  roots = new ArrayList<Node>();
                  for (String root : new String[]{"1", "2", "3"}) {
                      List<Node> second = new ArrayList<Node>();
                      for (String label : new String[]{"A", "B", "C", "D"}) {
                          List<Node> third = new ArrayList<Node>();
                          for (String l : new String[]{"a", "b", "c", "d"}) {
                              third.add(new Node(label + "-" + l, null));
                          }
                          second.add(new Node(label, third));
                      }
                      roots.add(new Node("&Root <" + root +"> & --->", second));
                  }
              }
          
              public List<Node> getRoots() {
                  return roots;
              }
          
          }
          

           

           

          <h:form>
               <rich:tree toggleType="ajax" var="node">
                   <rich:treeModelRecursiveAdaptor roots="#{testBean.roots}" nodes="#{node.children}">
                       <rich:treeNode>
                           <h:outputText value="#{node.label}" />
                       </rich:treeNode>
                   </rich:treeModelRecursiveAdaptor>
               </rich:tree>
           </h:form>
          

           

          The whole application is available on GitHub: https://github.com/papousek/richfaces-sanbox/tree/thread201994

           

          If the code sample doeasn't solve your problem, could you please provide the minimal code leading to the described behaviour?

          • 2. Re: richtree not expanding with special symbols like (&,>)
            Dinesh Lomte Newbie

            Hi Jan Papousek,

            I incorporated the code as shared by you but could not execute to see the child nodes on click of the parent node. Surprisingly even I tried with the code base as existing in the showcase http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=treeAdaptors&skin=blueSkybut had the same issue not sure if I am missing something OR going across a wrong path. Below is the exception what I am getting on click of the root node(s). I am using the latest api’s as provided in the 4.2.3 version of jar. Please provide me with your valuable inputs.

            javax.faces.convert.ConverterException: Row key converter is not available for model j_idt8

                  at org.richfaces.component.AbstractTree.convertDeclarativeKeyToString(AbstractTree.java:576)

                  at org.richfaces.convert.DeclarativeModelSequenceKeyConverter.getAsString(DeclarativeModelSequenceKeyConverter.java:90)

                  at org.richfaces.component.UIDataAdaptor.getRowKeyAsString(UIDataAdaptor.java:649)

                  at org.richfaces.component.UIDataAdaptor.getContainerClientId(UIDataAdaptor.java:671)

                  at javax.faces.component.UIComponentBase.getClientId(UIComponentBase.java:293)

                  at org.richfaces.component.UIDataAdaptor.restoreChildState(UIDataAdaptor.java:391)

                  at org.richfaces.component.UIDataAdaptor.restoreChildState(UIDataAdaptor.java:372)

                  at org.richfaces.component.AbstractTree.restoreChildState(AbstractTree.java:544)

                  at org.richfaces.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:280)

                  at org.richfaces.component.AbstractTree.restoreFromSnapshot(AbstractTree.java:538)

                  at org.richfaces.component.AbstractTree.walkModelChildren(AbstractTree.java:508)

                  at org.richfaces.component.AbstractTree.walkModel(AbstractTree.java:490)

                  at org.richfaces.component.AbstractTree.walk(AbstractTree.java:436)

                  at org.richfaces.component.UIDataAdaptor.visitDataChildren(UIDataAdaptor.java:1269)

                  at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1347)

                  at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)

                  at javax.faces.component.UIForm.visitTree(UIForm.java:371)

                  at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)

                  at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)

                  at org.richfaces.context.ExtendedPartialViewContextImpl.visitActivatorComponent(ExtendedPartialViewContextImpl.java:440)

                  at org.richfaces.context.ExtendedPartialViewContextImpl.visitActivatorAtRender(ExtendedPartialViewContextImpl.java:326)

                  at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialRenderPhase(ExtendedPartialViewContextImpl.java:245)

                  at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:194)

                  at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:981)

                  at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)

                  at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:409)

                  at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)

                  at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)

                  at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)

                  at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

                  at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)

                  at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)

                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)

                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

                  at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)

                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)

                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)

                  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)

                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)

                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)

                  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)

                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)

                  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)

                  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)

                  at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)

                  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                  at java.lang.Thread.run(Thread.java:619)

             

            • 3. Re: richtree not expanding with special symbols like (&,>)
              Dinesh Lomte Newbie

              I got resolved the above exception by adding

               

              rowKeyConverter="org.richfaces.StringSequenceRowKeyConverter"