In my jsf page I have a <p:treeTable>
structure. I am trying to delete a node when clicking on a small icon placed on one of the columns:
<p:column rendered="#{node.isLeaf}" style="width:70px">
<p:commandLink styleClass="entity-icon" update=":clipboard-tree" ajax="true"
action="#{clipboardManager.removeClipboard(node)}" >
<p:graphicImage value="/resources/images/delete.png" styleClass="entity-icon-tree"/>
</p:commandLink>
</p:column>
And my removeClipboard function looks something like this:
public void removeClipboard(FindResult result){
TreeNode node = result.getNode();
node.getChildren().clear();
node.getParent().getChildren().remove(node);
node.setParent(null);
node = null;
}
This is similar to the showcase offered by primefaces. However the tree get's updated only on the second click and I get the following exception:
[Index: 0, Size: 0] with root cause java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
This happens only when I try to delete the last child of a node. Does anybody have an idea why this is happening? Or how I can fix it? Thank you in advance.