1 Reply Latest reply on Jun 24, 2008 5:34 AM by Li wy

    context menu problem with tree

    Li wy Newbie

      I want to add context menu with tree. The page is

      <rich:tree switchType="client" nodeSelectListener="#{catalogBean.processSelect}"
       reRender="catalog_content_table" ajaxSubmitSelection="true" ajaxSingle="true">
       <rich:recursiveTreeNodesAdaptor roots="#{catalogBean.roots}"
       var="node" nodes="#{node.children}">
       <rich:treeNode>
       <h:outputText value="#{node.name}">
       <rich:componentControl event="oncontextmenu" for="catalog_tree_menu" operation="show">
       </rich:componentControl>
       </rich:treeNode>
       </rich:recursiveTreeNodesAdaptor>
      </rich:tree>
      


      But the context menu cannot be shown for the leaf nodes. The IE prompts:
      Line: 19
      Error: 'Richfaces.componntControl' is null or not a object.

      I ever tried another methods:
      <rich:tree switchType="client" nodeSelectListener="#{catalogBean.processSelect}"
       reRender="catalog_content_table" ajaxSubmitSelection="true" ajaxSingle="true">
       <rich:recursiveTreeNodesAdaptor roots="#{catalogBean.roots}"
       var="node" nodes="#{node.children}">
       <rich:treeNode>
       <h:outputText value="#{node.name}"/>
       <rich:contextMenu attached="true" submitMode="ajax">
       <rich:menuItem ajaxSingle="true" value="Show">
       </rich:menuItem>
       </rich:contextMenu>
       </rich:treeNode>
       </rich:recursiveTreeNodesAdaptor>
      </rich:tree>
      


      But I got follow errors in IE.
      type Exception report
      
      message
      
      description The server encountered an internal error () that prevented it from fulfilling this request.
      
      exception
      
      javax.servlet.ServletException: srcBegin > srcEnd
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
       org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
       org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:256)
       org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:362)
       org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:488)
      
      
      root cause
      
      java.lang.StringIndexOutOfBoundsException: srcBegin > srcEnd
       java.lang.AbstractStringBuilder.getChars(AbstractStringBuilder.java:327)
       java.lang.StringBuilder.getChars(StringBuilder.java:55)
       com.sun.faces.renderkit.html_basic.HtmlResponseWriter.flushAttributes(HtmlResponseWriter.java:981)
       com.sun.faces.renderkit.html_basic.HtmlResponseWriter.closeStartIfNecessary(HtmlResponseWriter.java:937)
       com.sun.faces.renderkit.html_basic.HtmlResponseWriter.flush(HtmlResponseWriter.java:310)
       org.richfaces.renderkit.TemplateEncoderRendererBase.writeScriptBody(TemplateEncoderRendererBase.java:151)
       org.richfaces.renderkit.html.ContextMenuRendererBase.encodeChildren(ContextMenuRendererBase.java:115)
       javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:832)
       org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:284)
       org.richfaces.renderkit.TreeRendererBase$DataVisitorWithLastElement.process(TreeRendererBase.java:265)
       org.richfaces.model.AbstractTreeDataModel.processElement(AbstractTreeDataModel.java:124)
       org.richfaces.model.StackingTreeModel.doWalk(StackingTreeModel.java:278)
       org.richfaces.model.StackingTreeModel$Visitor1.process(StackingTreeModel.java:391)
       org.richfaces.model.StackingTreeModel$ShiftingDataVisitor.process(StackingTreeModel.java:426)
       org.richfaces.model.StackingTreeModel$1.process(StackingTreeModel.java:316)
       org.richfaces.model.SequenceDataModel.walk(SequenceDataModel.java:63)
       org.richfaces.model.StackingTreeModel.doWalk(StackingTreeModel.java:300)
       org.richfaces.model.StackingTreeModel$Visitor1.process(StackingTreeModel.java:391)
       org.richfaces.model.StackingTreeModel$ShiftingDataVisitor.end(StackingTreeModel.java:436)
       org.richfaces.model.StackingTreeModel.doWalk(StackingTreeModel.java:325)
       org.richfaces.model.StackingTreeModel.walk(StackingTreeModel.java:363)
       org.richfaces.component.UITree.walk(UITree.java:386)
       org.richfaces.renderkit.TreeRendererBase.writeContent(TreeRendererBase.java:631)
       org.richfaces.renderkit.TreeRendererBase.encodeChildren(TreeRendererBase.java:574)
       javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:832)
       com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
       com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:106)
       javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:832)
       com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
       com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:178)
       com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:126)
       javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:832)
       org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:220)
       org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:215)
       org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
       javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:832)
       com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
       com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:178)
       com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:126)
       javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:832)
       javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
       javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
       javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:832)
       javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
       javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
       com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:271)
       com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:202)
       org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
       com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
       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:147)
       org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:256)
       org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:362)
       org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:488)
      


      But, if I change the context menu submitMode to 'none', it works.
      <rich:tree switchType="client" nodeSelectListener="#{catalogBean.processSelect}"
       reRender="catalog_content_table" ajaxSubmitSelection="true" ajaxSingle="true">
       <rich:recursiveTreeNodesAdaptor roots="#{catalogBean.roots}"
       var="node" nodes="#{node.children}">
       <rich:treeNode>
       <h:outputText value="#{node.name}"/>
       <rich:contextMenu attached="true" submitMode="none">
       <rich:menuItem ajaxSingle="true" value="Show">
       </rich:menuItem>
       </rich:contextMenu>
       </rich:treeNode>
       </rich:recursiveTreeNodesAdaptor>
      </rich:tree>
      


      However, if the submitMode is 'none', it's not useful.
      Who can help me? Thanks.