2
votes

Currently I am working on a project that use primefaces 3.4.1 version which does not support drag and drop in tree component. So I am using a contextMenu instead of drag and drop.

<p:tree id="treeHierarchy"
            value="#{hierarchyManagementBackingBean.root}" var="node"
            dynamic="true" selectionMode="single" cache="false"
            style="width:99%;" selection="#{hierarchyManagementBackingBean.selectedNode}">

            <p:treeNode id="idtreenode">
                <h:outputText value="#{node.name} (#{node.entityType})" />
            </p:treeNode>
</p:tree>


<p:contextMenu for="treeHierarchy">
            <p:menuitem value="Cut" actionListener="#{hierarchyManagementBackingBean.cutNode}"/>
            <p:menuitem value="Paste" actionListener="#{hierarchyManagementBackingBean.pasteNode}"/>
</p:contextMenu>

In backing bean,

public void cutNode() {
    ChildNodeDTO select = (ChildNodeDTO) selectedNode.getData();
    selectedNode.getParent().getChildren().remove(selectedNode);
    selectedNode.setParent(null);
    selectedNode = null;
}

Is there a way to refresh parent node from backing bean so that change can see on the tree?

Thanks.

2

2 Answers

0
votes

No, you can only update the full tree afaik

0
votes

Actually I found a way to achieve this functionality.

<h:form id="frmHierachiManage" styleClass="treeForm">
-- tree inside this form
</h:form>

then in the backing bean,

RequestContext.getCurrentInstance().update("frmHierachiManage");

this updated the tree view.