Deleting a node having input field from TreeTable

UI Components for JSF
Post Reply
Darac
Posts: 17
Joined: 22 Feb 2012, 14:32

08 Jun 2012, 15:22

Hi,

I have a TreeTable that has inputText fields for each node. Next to the inputText there is a button that, when clicked, is supposed to delete the node:

Code: Select all

        <p:treeTable id="main-tree" var="n" ...>

            <p:column>
                <f:facet name="header">Name</f:facet>
                <h:outputText value="#{n.name}"/>
            </p:column>

            <p:column>
                <f:facet name="header">Value</f:facet>
                <p:inputText value="#{n.value}"/>
            </p:column>

            <p:column>
                <p:commandButton icon="ui-icon-minus" process="@this" update="main-tree" action="#{model.removeListEntry(n)}"/>
            </p:column>

        </p:treeTable>
Node is being deleted like this:

Code: Select all


    public void removeListEntry(NodeData nodeData) {
        TreeNode treeNode = nodeData.getTreeNode();
        assert treeNode != null;
        // Clear children
        treeNode.getChildren().clear();
        // Deatch from parent
        treeNode.getParent().getChildren().remove(treeNode);
        treeNode.setParent(null);
    }
The problem is that an exception is thrown upon deletion:

Code: Select all

2012-06-08 15:08:38,349 - ERROR - javax.enterprise.resource.webcontainer.jsf.application - Error Rendering View[/operation-exec.xhtml]
java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
 at java.util.ArrayList.RangeCheck(ArrayList.java:547) ~[na:1.6.0_29]
 at java.util.ArrayList.get(ArrayList.java:322) ~[na:1.6.0_29]
 at org.primefaces.component.api.UITree.findTreeNode(UITree.java:112) ~[primefaces-3.3.jar:na]
 at org.primefaces.component.api.UITree.findTreeNode(UITree.java:120) ~[primefaces-3.3.jar:na]
 at org.primefaces.component.api.UITree.setRowKey(UITree.java:79) ~[primefaces-3.3.jar:na]
 at org.primefaces.component.api.UITree.visitTree(UITree.java:408) ~[primefaces-3.3.jar:na]
 at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) ~[jsf-api.jar:2.1.3-FCS]
 at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) ~[jsf-api.jar:2.1.3-FCS]
 at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:163) ~[jsf-api.jar:2.1.3-FCS]
 at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) ~[jsf-api.jar:2.1.3-FCS]
 at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) ~[jsf-api.jar:2.1.3-FCS]
 at javax.faces.component.UIForm.visitTree(UIForm.java:344) ~[jsf-api.jar:2.1.3-FCS]
 at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) ~[jsf-api.jar:2.1.3-FCS]
 at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) ~[jsf-api.jar:2.1.3-FCS]
 at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:376) ~[jsf-impl.jar:2.1.3-FCS]
 at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:297) ~[jsf-impl.jar:2.1.3-FCS]
 at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183) ~[jsf-api.jar:2.1.3-FCS]
 at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:981) ~[jsf-api.jar:2.1.3-FCS]
 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756) ~[jsf-api.jar:2.1.3-FCS]
 at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:390) ~[jsf-impl.jar:2.1.3-FCS]
 at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) [jsf-impl.jar:2.1.3-FCS]
 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [jsf-impl.jar:2.1.3-FCS]
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl.jar:2.1.3-FCS]
 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl.jar:2.1.3-FCS]
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jsf-api.jar:2.1.3-FCS]
...
Any suggestions, should I do deletion differently? What am I doing wrong?
PrimeFaces 3.3 / Mojarra 2.1.3 (FCS b02) / Glassfish 3.1.1

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

06 Jul 2012, 04:31

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 50 guests