Reputation: 33
Is it possible not to remove the node from the original PrimeFacesTree after dragging it? The default behaviour is that a node that was dragged and dropped in another place is removed. Can i prevent that from happening?
I'm using Primefaces 4.0
Upvotes: 3
Views: 2353
Reputation: 1964
There isn't any premade attribute to duplicate node on dropEvent.
The solution is to add a listener to your <p:tree>
element :
<p:tree listener="#{managingBean.onDragDrop}" />
Then you need to re-create node on initial location by duplicating it in your backbean method :
public void onDragDrop(TreeDragDropEvent event) {
TreeNode dragNode = event.getDragNode();
TreeNode dropNode = event.getDropNode();
int dropIndex = event.getDropIndex();
// Logic to repopulate initial Tree element
}
And don't forget to re-draw your tree
Upvotes: 1