0 Replies Latest reply on May 14, 2007 11:41 AM by Melanie Ntolo

    Strange behavior with the Tree component - RichFaces 3.0.1RC

    Melanie Ntolo Newbie

      Since I began to use RichFaces 3.0.1, I get a strange behavior with the Tree component.

      I'm new with RichFaces, I don't know how to get out of this issue.

      I am using Seam + RichFaces + Ajax4jsf + Facelets.

      I'd simply like to add or remove a node from the tree by using a contextual menu.

      With RichFaces 3.0.0 it (add + remove) worked well (by clicking on a button ).

      But with RichFaces 3.0.1RC2, neither the button nor the context menu works.
      Sometimes, it works by chance (I can't say why) but most of the time I get a java.lang.NullPointerException
      at org.richfaces.renderkit.NodeRendererBase$TreeNodeOptions.(NodeRendererBase.java:47).

      The code I use to delete or add a node is really simple.

      public void removeChild( Object child )
       {
       TreeNode treeNode = getElements().remove( child );
       if ( treeNode != null )
       {
       treeNode.setParent( null );
       }
       }
      
      public TPZITreeNode findOrCreateNode( TPZResourceBean childResource, TPZITreeNode parent )
       {
       TPZITreeNode node = m_resourceCache.get( childResource );
       if ( node == null )
       {
       node = createNode( childResource );
       m_resourceCache.put( childResource, node );
       parent.addElementNode( node );
       }
       return node;
       }


      My tree page looks like this:

      <a4j:outputPanel layout="block" id="treePanel" ajaxRendered="true">
      
       <rich:tree name="adminTree" style="width:300px" value="#{TPZAdminTreeBean.data}" var="item"
       nodeFace="#{item.type}"
       ajaxSubmitSelection="true"
       icon="#{item.icon}"
       iconLeaf="#{item.iconLeaf}"
       switchType="ajax"
       binding="#{TPZAdminTreeBean.tree}"
       componentState="#{TPZAdminTreeBean.dataComponentState}">
      
       <rich:treeNode value="item" ajaxSubmitSelection="true" id="adminSystemNode" type="SYSTEM" nodeSelectListener="#{TPZAdminTreeBean.onTreeSelection}">
       <ddm:dropDownMenu event="oncontextmenu" id="SystemItem" value="#{item.resource.name}">
       <mc:menuItem id="adminItem" value="New Domain" submitMode="ajax" ajaxSingle="true" onclick="openNewWindow('../new/TPZAdminNewDomain.seam')"/>
       </ddm:dropDownMenu>
       </rich:treeNode>
      
       <rich:treeNode value="item" ajaxSubmitSelection="true" id="adminDomainNode" type="DOMAIN" nodeSelectListener="#{TPZAdminTreeBean.onTreeSelection}">
       <ddm:dropDownMenu event="oncontextmenu" id="DomainItem" value="#{item.resource.name}">
       <mc:menuItem id="DomainItem11" value="Delete" submitMode="ajax" ajaxSingle="true" icon="/view/images/Clear16.png" action="#{TPZAdminTreeBean.deleteNode(item)}" reRender="treePanel"/>
       </ddm:dropDownMenu>
       </rich:treeNode>
      
       <rich:treeNode name="adminLinkNode" ajaxSubmitSelection="true" value="item" id="adminLinkNode" type="LINK" nodeSelectListener="#{TPZAdminTreeBean.onTreeSelection}">
       <s:link value="#{item.resource.name}" target="DetailWindow" action="#{TPZAdminTreeBean.forwardToDetailPage('LINK')}" onclick="openDetailWindow('../detail/link/TPZNOCDetailLink.seam')"/>
       </rich:treeNode>
      
       <rich:treeNode name="adminOtuNode" ajaxSubmitSelection="true" value="item" id="adminOtuNode" type="OTU" nodeSelectListener="#{TPZAdminTreeBean.onTreeSelection}">
       <ddm:dropDownMenu event="oncontextmenu" id="OtuItem" value="#{item.resource.name}">
       <mc:menuItem id="OtuItem1" value="Show details" submitMode="ajax" ajaxSingle="true" action="#{TPZAdminTreeBean.forwardToDetailPage('OTU')}" onclick="changePageURL('OTU')" />
       <mc:menuSeparator id="OtumenuSeparator"/>
       <mc:menuItem id="OtuItem4" value="Move to" submitMode="ajax" ajaxSingle="true" onclick="openMoveWindow('../move/TPZMoveDomainList.seam')" action="#{TPZAdminTreeBean.setNodeToMove(item)}" immediate="true"/>
       <mc:menuItem id="OtuItem5" value="Copy to" submitMode="ajax" ajaxSingle="true" onclick="openMoveWindow('../move/TPZCopyDomainList.seam')" action="#{TPZAdminTreeBean.setNodeToMove(item)}" immediate="true"/>
       </ddm:dropDownMenu>
       <a4j:commandButton image="/view/images/Clear16.png" immediate="true" ajaxSingle="true" type="image"
       action="#{TPZAdminTreeBean.deleteNode(item)}" reRender="treePanel">
       </a4j:commandButton>
      
       <a4j:commandButton image="/view/images/Edit16.png" immediate="true" ajaxSingle="true"
       onclick="openEditWindow('../edit/TPZAdminEditOTU.seam')" action="#{TPZAdminTreeBean.setNodeToEdit(item)}">
       </a4j:commandButton>
       </rich:treeNode>
      
      
       </rich:tree>
      
      </a4j:outputPanel>


      I get this exception:
      java.lang.NullPointerException
       at org.richfaces.renderkit.NodeRendererBase$TreeNodeOptions.<init>(NodeRendererBase.java:47)
       at org.richfaces.renderkit.NodeRendererBase.getDropzoneScriptOptions(NodeRendererBase.java:297)
       at org.richfaces.renderkit.html.TreeNodeRenderer.doEncodeBegin(TreeNodeRenderer.java:195)
       at org.richfaces.renderkit.html.TreeNodeRenderer.doEncodeBegin(TreeNodeRenderer.java:86)
       at org.ajax4jsf.framework.renderer.RendererBase.encodeBegin(RendererBase.java:101)
       at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:512)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java:280)
       at org.richfaces.renderkit.TreeRendererBase$DataVisitorWithLastElement.process(TreeRendererBase.java:98)
       at org.richfaces.component.CacheableTreeDataModel$Visitor.process(CacheableTreeDataModel.java:54)
       at org.richfaces.component.AbstractTreeDataModel.processElement(AbstractTreeDataModel.java:134)
       at org.richfaces.component.TreeDataModel.walk(TreeDataModel.java:74)
       at org.richfaces.component.TreeDataModel.walk(TreeDataModel.java:117)
       at org.richfaces.component.TreeDataModel.walk(TreeDataModel.java:117)
       at org.richfaces.component.TreeDataModel.walk(TreeDataModel.java:117)
       at org.richfaces.component.CacheableTreeDataModel.walk(CacheableTreeDataModel.java:121)
       at org.richfaces.component.UITree.walk(UITree.java:298)
       at org.richfaces.renderkit.TreeRendererBase.writeContent(TreeRendererBase.java:374)
       at org.richfaces.renderkit.TreeRendererBase.encodeChildren(TreeRendererBase.java:283)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:524)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChildren(RendererBase.java:262)
       at org.ajax4jsf.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:79)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:524)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.framework.renderer.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:159)
       at org.ajax4jsf.framework.renderer.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:97)
       at org.ajax4jsf.framework.renderer.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:150)
       at org.ajax4jsf.framework.renderer.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:97)
       at org.ajax4jsf.framework.renderer.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:150)
       at org.ajax4jsf.framework.renderer.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:125)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot.encodeAjax(AjaxViewRoot.java:549)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot$4.invokeRoot(AjaxViewRoot.java:380)
       at org.ajax4jsf.framework.ajax.JsfOneOneInvoker.invokeOnRegionOrRoot(JsfOneOneInvoker.java:53)
       at org.ajax4jsf.framework.ajax.AjaxContext.invokeOnRegionOrRoot(AjaxContext.java:191)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:397)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:234)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:580)
       at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:181)
       at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       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.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:209)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:166)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:139)
       at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
       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.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:595)
      15:00:04,421 ERROR [ExceptionFilter] uncaught exception


      What am I doing wrong?

      I urgently need help,

      Thanks very much in advance for having a look.