New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The p:tree with multipleDrag="true" feature doesn't seem to work correctly #4478

Closed
mertsincan opened this Issue Jan 29, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@mertsincan
Copy link
Member

mertsincan commented Jan 29, 2019

Reported By PRO User;

Here is the example code:

@Named
@SessionScoped
public class TreeDragDropView implements Serializable
{
  /**
   *
   */
  private static final long serialVersionUID = 1L;
  private TreeNode rootNode;
  private TreeNode[] selectedNodes;

  @PostConstruct
  public void init()
  {
    rootNode = new DefaultTreeNode("Root", null);
    new DefaultTreeNode("Node0", rootNode);
    new DefaultTreeNode("Node1", rootNode);
    new DefaultTreeNode("Node2", rootNode);
    new DefaultTreeNode("Node3", rootNode);
    new DefaultTreeNode("Node4", rootNode);
    new DefaultTreeNode("Node5", rootNode);
  }

  public TreeNode getRootNode()
  {
    System.out.println("getRoot");
    return rootNode;
  }

  public void setRootNode(TreeNode rootNode)
  {
    this.rootNode = rootNode;
  }

  public TreeNode[] getSelectedNodes()
  {
    return selectedNodes;
  }

  public void setSelectedNodes(TreeNode[] selectedNodes)
  {
    System.out.println(Arrays.toString(selectedNodes));
    this.selectedNodes = selectedNodes;
  }

  public void onDragDrop(TreeDragDropEvent event)
  {
    TreeNode[] dragNodes = event.getDragNodes();
    TreeNode dropNode = event.getDropNode();
    int dropIndex = event.getDropIndex();
    String data = "";
    for (TreeNode node : dragNodes)
    {
      data += " " + node.getData();
    }
    System.out.println("Dragged " + data + " Dropped on " + dropNode.getData() + " at " + dropIndex);
  }
}
<h:form id="form">
<p:tree value="#{treeDragDropView.rootNode}" var="node" selectionMode="checkbox"
selection="#{treeDragDropView.selectedNodes}" draggable="true" droppable="true" dragdropScope="demo"
multipleDrag="true" dropRestrict="sibling">
<p:ajax event="dragdrop" listener="#{treeDragDropView.onDragDrop}" />
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
</h:form>

When I select Node1 and Node2 and drag and drop it between Node3 and Node4, It looks good on the first hand:
The result is:
Node0
Node3
Node1
Node2
Node4
Node5

This is what I expected, but after page reload it looks like this:
Node0
Node2
Node1
Node3
Node4
Node5

@mertsincan mertsincan added this to the 7.0 milestone Jan 29, 2019

@mertsincan mertsincan self-assigned this Jan 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment