-
1. unselecting tree node
lfryc May 10, 2011 9:28 AM (in response to eunnini)Hello, the feature you are writing about seems will be implemented in scope of
-
2. unselecting tree node
lfryc May 10, 2011 9:29 AM (in response to eunnini)Though you should still be able to deselect tree node programatically using selection listener.
-
3. unselecting tree node
ilya_shaikovsky May 10, 2011 10:16 AM (in response to lfryc)Lukas is right there is:
UITree.setSelection(collection). it should be passed with the rowKey's of selected nodes. (actually while multi selection is not implemented with single rowKey). Or in your case with null value or empty collection (still need to try)
But b.t.w. I found some problems there:
1) when you clicking the node second time it rises ajax request also. And probably fires selectionChangeListener. But actually it differs from 3.3.x and I'm not sure than now it's more properly behaves. Actually there were no selection change in case of subsequent clicks onm the same node, so event name slightly confuses. But as much users asked about that in 3.3.x - seems like really valid. But we need to document that. (And need to ensure that we will provide the way to cancel the request on subsequent clicks on the same treeNode in case selection not really changes. At least using something like onbeforeselectionchange="if (event.oldSelection...) return false;").
-
4. unselecting tree node
eunnini May 10, 2011 12:07 PM (in response to eunnini)So, the problem is that I'm using 3.3.3 version.
As I can see there is no possibility to fire selection event when I click on already selected item
-
5. unselecting tree node
ilya_shaikovsky May 10, 2011 3:46 PM (in response to eunnini)Ah.. yup.. in 3.3.x you should turn built-in selection processing off. And use a4j:support on onclick instead. And use advisors for selection/expansion managing.
-
6. unselecting tree node
eunnini May 10, 2011 4:21 PM (in response to ilya_shaikovsky)Yes, but the problem still exists .
I already tried onclick with a4j:support, but the problem is that the onclick method is invoked even if I expand/collapse tree node.
Is there a posibility to know what action is fired, node click or node expand/collapse
-
7. unselecting tree node
ilya_shaikovsky May 10, 2011 5:00 PM (in response to eunnini)doh.. probably could use original target and check if it's div with expand/collapse icon
-
8. Re: unselecting tree node
bcn Jul 20, 2011 2:11 PM (in response to ilya_shaikovsky)Hi,
in RichFaces 4 I try to unselect a node in a treeSelectionChangeListener with setSelection(null).
Furthermore, for the selected node I change the rendered attribute to false. In this case I get:
20:00:32,894 SEVERE [org.richfaces.log.Context] (http--127.0.0.1-8080-3) null: java.lang.NullPointerException
at org.richfaces.renderkit.TreeRendererBase.encodeSelectionStateInput(TreeRendererBase.java:133) [richfaces-components-ui-4.0.0-20110322.220419-243.jar:]
at org.richfaces.renderkit.html.TreeRenderer.encodeEnd(TreeRenderer.java:145) [richfaces-components-ui-4.0.0-20110322.220419-243.jar:]
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:2.1.2-FCS]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:2.1.2-FCS]
at org.richfaces.context.ExtendedPartialViewContextImpl$RenderVisitCallback.visit(ExtendedPartialViewContextImpl.java:514) [richfaces-core-impl-4.0.0-20110325.220425-378.jar:]
at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:337) [richfaces-core-impl-4.0.0-20110325.220425-378.jar:]
at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1235) [richfaces-components-ui-4.0.0-20110322.220419-243.jar:]
I also tried to select another node or set an empty collection. Nothing helps. The original selection is maintained and leads to the exception.
Any idea?
Thanks
-
9. Re: unselecting tree node
bcn Jul 21, 2011 2:29 PM (in response to bcn)Update: I have realized that setSelection(null) or setSelection(anotherNode) does NOT unselect the selected node, at least within a selection change listener.
If you then click again the same node, no change event is generated.
Any help, please!
-
10. Re: unselecting tree node
bcn Jul 22, 2011 5:30 AM (in response to bcn)I found a workaround: you can throw a AbortProcessingException, so the selection is not restored. The drawback is that it logs a SEVERE error stack trace. Not very nice. Isn't there a way to gently deselect the node?
Thanks,
Ulrich
-
-
12. Re: unselecting tree node
asterius Nov 29, 2012 11:04 AM (in response to bcn)I exacly have the same problem, using RF4.2.3. I want to programatically unselect my node.
I binded the tree component in my javaclass (UITree)
UITree.setSelection(null) do not work.
Do you have any workaround here?
Thanks!