Skip to content
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

Tree: DragDrop between trees get NPE in TabView DataModel #9543

Closed
lih13800 opened this issue Dec 23, 2022 · 3 comments · Fixed by #9550
Closed

Tree: DragDrop between trees get NPE in TabView DataModel #9543

lih13800 opened this issue Dec 23, 2022 · 3 comments · Fixed by #9550
Assignees
Labels
🐞 defect Bug...Something isn't working
Milestone

Comments

@lih13800
Copy link

lih13800 commented Dec 23, 2022

Describe the bug

In the TabView with dynamic number of tabs (DataModel in the showcase http://www.primefaces.org:8080/showcase/ui/panel/tabView.xhtml?jfwid=e3889), drag-drop event between trigger a NullPointerException in TreeRenderer.java

SEVERE: java.lang.NullPointerException
	at org.primefaces.component.tree.TreeRenderer.decodeDragDrop(TreeRenderer.java:163)
	at org.primefaces.component.tree.TreeRenderer.decode(TreeRenderer.java:67)
	at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:514)
	at org.primefaces.component.tree.Tree.processDecodes(Tree.java:270)
Tree otherTree = (Tree) tree.findComponent(separator + dragSource);
otherTree.setRowKey(otherTree.getValue(), rowKey);

https://github.com/primefaces/primefaces/blob/master/primefaces/src/main/java/org/primefaces/component/tree/TreeRenderer.java#L162-L163
In the code of TreeRenderer.java, "dragSource" is the id of the tree.

  • The TabView with static tab number provides the correct component path, like this pattern :staticTabView:testTabForm:tree1.
  • But TabView with dynamic tab number provides the component path with tab index like this dynamicTabView:0:testTabForm:tree1 (0 is tab index).

This might be the reason cause the findComponent() method return null value.

primefaces-test-master.zip

Reproducer

  1. Go the lower TabView and select a tab
  2. Drag the nodes from one tree to the other one
  3. See error
SEVERE: java.lang.NullPointerException
	at org.primefaces.component.tree.TreeRenderer.decodeDragDrop(TreeRenderer.java:163)
	at org.primefaces.component.tree.TreeRenderer.decode(TreeRenderer.java:67)
	at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:514)
	at org.primefaces.component.tree.Tree.processDecodes(Tree.java:270)

Expected behavior

There should be no NPE problem. The expected Result should the same as upper TabView.

PrimeFaces edition

None

PrimeFaces version

12.0.0

Theme

No response

JSF implementation

Mojarra

JSF version

2.2

Java version

JavaSE-1.8

Browser(s)

No response

@lih13800 lih13800 added ‼️ needs-triage Issue needs triaging 🐞 defect Bug...Something isn't working labels Dec 23, 2022
@jepsar
Copy link
Member

jepsar commented Dec 23, 2022

I don't see a tree and I don't understand what to drag from where to where.

@melloware
Copy link
Member

@jepsar i was able to reproduce the NPE.

@melloware
Copy link
Member

Bug is definitely right here:

String separator = Character.toString(UINamingContainer.getSeparatorChar(context));
Tree otherTree = (Tree) tree.findComponent(separator + dragSource);

@melloware melloware removed the ‼️ needs-triage Issue needs triaging label Dec 24, 2022
melloware added a commit to melloware/primefaces that referenced this issue Dec 24, 2022
@melloware melloware self-assigned this Dec 24, 2022
@melloware melloware added this to the 13.0.0 milestone Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 defect Bug...Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants