Error during adding new node to the tree

UI Components for JSF
Post Reply
bartman12
Posts: 1
Joined: 20 Apr 2012, 15:13

20 Apr 2012, 16:04

Hi,
I'm trying to add a new node to the tree.I have made a commundButton which is responsible for it.
When I add new node to the nodes which I have created in my java constructor everything is ok, but when I add a node and then I add a node to the one I have created before StuckTrace appears.
This is my xhtml code:

Code: Select all

<h:form>  
   <p:commandButton value="Add node" update="treeSingle" actionListener="#{treeBean.addNode}" ></p:commandButton>
  
   <p:tree id="treeSingle" value="#{treeBean.root}" var="node"  
            selectionMode="single"  
            selection="#{treeBean.selectedNode}">  
        <p:treeNode>  
            <h:outputText value="#{node}" />  
        </p:treeNode>  
    </p:tree>  
  
</h:form>  
And Java class:

Code: Select all

	public TreeBean() {
		root = new DefaultTreeNode("Root", null);
		TreeNode node0 = new DefaultTreeNode("Node 0", root);
		TreeNode node1 = new DefaultTreeNode("Node 1", root);
		TreeNode node100 = new DefaultTreeNode("Node 1.0.0", node10);
	}

	public void addNode() {
		if (selectedNode != null) {
			TreeNode node = node=new DefaultTreeNode("New node", selectedNode);
			
		}
	}
Error message:

Code: Select all

WARNING: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.RangeCheck(ArrayList.java:547)
	at java.util.ArrayList.get(ArrayList.java:322)
	at org.primefaces.component.api.UITree.findTreeNode(UITree.java:112)
	at org.primefaces.component.api.UITree.findTreeNode(UITree.java:120)
	at org.primefaces.component.api.UITree.setRowKey(UITree.java:79)
	at org.primefaces.component.tree.TreeRenderer.decodeSelection(TreeRenderer.java:60)
	at org.primefaces.component.tree.TreeRenderer.decode(TreeRenderer.java:36)
	at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)
	at org.primefaces.component.api.UITree.processDecodes(UITree.java:171)
	at org.primefaces.component.tree.Tree.processDecodes(Tree.java:343)
	at javax.faces.component.UIForm.processDecodes(UIForm.java:225)
	at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
	at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
	at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:933)
	at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	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:191)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	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:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:662)

rkrenn
Posts: 33
Joined: 26 Jul 2011, 03:55
Location: Austria

06 Jul 2012, 04:29

i confirm this issue. other users report this problem too:

viewtopic.php?f=3&t=22551&p=69044&hilit ... ror#p69044

viewtopic.php?f=3&t=20416&p=63859&hilit ... ode#p63859

http://code.google.com/p/primefaces/iss ... t=&id=3728

after changing a tree structure programatically, exceptions like this occur if e.g. selecting a node:

Code: Select all

INFO: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.get(ArrayList.java:322)
        at org.primefaces.component.api.UITree.findTreeNode(UITree.java:112)
hint for others running into this problem: as a temporary workaround for node selection i use a node label span onclick that triggers a prepared RemoteCommand with parameter. thus i can disable node selection and problem is challenged for now.

hth
Mojarra 2.1.28, PrimeFaces 3.3.1, Primefaces Extensions 0.7.0, libservlet3.1-java tomcat8, openjdk-8-jdk

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests