0 Replies Latest reply on Jun 5, 2008 8:31 AM by Alessio Maggiori

    tree and contextMenu exception

    Alessio Maggiori Newbie

      Hi
      in my app i have a tree with contextMenu for each child.
      If I try to add a node at runtime clicking on a button, and then rerender that tree, I've got an exception:

      2008-06-05 14:17:58,528 [http-8086-1] ERROR org.ajax4jsf.webapp.BaseXMLFilter - Exception in the filter chain
      javax.servlet.ServletException: srcBegin > srcEnd
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.StringIndexOutOfBoundsException: srcBegin > srcEnd
       at java.lang.AbstractStringBuilder.getChars(AbstractStringBuilder.java:327)
       at java.lang.StringBuilder.getChars(StringBuilder.java:55)


      that is my code:

      <a4j:outputPanel id="pnl_tree">
      <rich:tree id="id_tree" reRender="pnl_container" nodeSelectListener="#{treeModelBean.processRichiesta}" switchType="client" ajaxSubmitSelection="true" >
      
       <rich:treeNodesAdaptor id="request" nodes="#{treeModelBean.requests}" var="req">
       <rich:treeNode iconLeaf="/resources/img/icons/16/Medical-invoice-information-16x16.png" icon="/resources/img/icons/16/health-care-shield-16x16.png" oncontextmenu="return false;" >
       <h:outputLabel value="Richiesta: #{req.id} - #{req.data}" />
       </rich:treeNode>
      
       <rich:treeNodesAdaptor id="impegn" var="imp" nodes="#{req.impegnList}">
       <rich:treeNode iconLeaf="/resources/img/icons/16/Medical-invoice-information-16x16.png" icon="/resources/img/icons/16/Medical-invoice-information-16x16.png" oncontextmenu="return false;">
       <h:outputLabel id="impm" value="Impegnativa: #{imp.id} - #{imp.descr}" />
       <rich:contextMenu event="oncontextmenu" attachTo="impm" >
       <rich:menuItem ajaxSingle="true" value="Aggiungi Esame" action="#{treeModelBean.addExam}" id="addEx">
       <a4j:actionparam value="{imp}" assignTo="#{treeModelBean.selectedImp}" />
       </rich:menuItem>
       <rich:menuItem ajaxSingle="true" value="Modifica Impegnativa" action="#{treeModelBean.editImp}" id="editImp">
       <a4j:actionparam value="{imp}" assignTo="#{treeModelBean.selectedImp}" />
       </rich:menuItem>
       <rich:menuItem ajaxSingle="true" value="Elimina Impegnativa" action="#{treeModelBean.delImp}" id="delImp">
       <a4j:actionparam value="{imp}" assignTo="#{treeModelBean.selectedImp}" />
       </rich:menuItem>
       </rich:contextMenu>
       </rich:treeNode>
      
      
       <rich:treeNodesAdaptor id="exam" var="ex" nodes="#{imp.examList}">
       <rich:treeNode iconLeaf="/resources/img/icons/16/blood-16x16.png" icon="/resources/img/icons/16/blood-16x16.png" oncontextmenu="return false;">
      
       <h:outputLabel id="exm" value="Esame: #{ex.id} - #{ex.cod}" />
       <rich:contextMenu event="oncontextmenu" attachTo="exm" >
       <rich:menuItem value="Modifica Esame" action="#{treeModelBean.editExam}" id="editEx">
       <a4j:actionparam value="{imp}" assignTo="#{treeModelBean.selectedImp}" />
       <a4j:actionparam value="{ex}" assignTo="#{treeModelBean.selectedExam}" />
       </rich:menuItem>
       <rich:menuItem value="Elimina Esame" action="#{treeModelBean.delExam}" id="delEx">
       <a4j:actionparam value="{imp}" assignTo="#{treeModelBean.selectedImp}" />
       <a4j:actionparam value="{ex}" assignTo="#{treeModelBean.selectedExam}" />
       </rich:menuItem>
       </rich:contextMenu>
      
       </rich:treeNode>
      
       </rich:treeNodesAdaptor>
      
       </rich:treeNodesAdaptor>
      
       </rich:treeNodesAdaptor>
      
       <a4j:support event="onselected" action="#{treeModelBean.doSomething}" reRender="pnl_req,pnl_ex,pnl_imp" />
      </rich:tree>
      </a4j:outputPanel>
      
      <a4j:commandButton styleClass="bottone_lungo" oncomplete="Richfaces.showModalPanel('newRequestPanel');" action="#{treeModelBean.prepareNewRequest}" id="btnNewReq" value="Nuova Richiesta" reRender="pnl_tree" />


      If I remove contextMenu the app add a node and show it correctly.

      I'm using RF3.2.1 GA

      Thanks to all