-
1. Re: rich:tree with unselectable nodes
bleathem Jun 7, 2013 7:06 PM (in response to th.paulsen)Why do you not want the nodes to be selectable? Is it simply for aesthetic reasons? If so, have you considered simply using CSS to disable any styling changes when the node is selected?
Alternatively, a recent forum post (https://community.jboss.org/thread/228490) explores interacting with a tree's selection state, perhaps that post will give you some insight.
-
2. Re: rich:tree with unselectable nodes
th.paulsen Jun 10, 2013 4:54 AM (in response to bleathem)Sorry for my late anwer, but the weekend...
Not not only for aesthetic reasons, the user has no right to select (and work) with that node. But he may work with one of the children.
Playing with the css styles will not prevent events to be fired.
Same with handling these restrictions on the server. It is possible, but I want to use the onselectionchange event to close the surrounding popup only when a valid node is selcted.
-
3. Re: rich:tree with unselectable nodes
bleathem Jun 11, 2013 1:06 AM (in response to th.paulsen)No JS API for RF 4 - this is a top-level goal for RF 5. You can however look for clues in the javascript source:
As for your problem, you can solve it with javascript. Add a beforeselectionchange listener that looks for a marker class on the tree node, and return false if that marker class is/is-not present, and you don't want your node to be selectable.
-
4. Re: rich:tree with unselectable nodes
th.paulsen Jun 11, 2013 1:34 AM (in response to bleathem)As I wrote in my question:
Then I tried an "onbeforeselectionchange" JS listener, but I havn't found a n attribute in the event which shows me the source (trreode) of the event.
-
5. Re: rich:tree with unselectable nodes
bleathem Jun 11, 2013 1:39 AM (in response to th.paulsen)Sorry, it's late
Does "event.data.newSelection" not contain what you are looking for? If it doesn't it's a bug, please file a jira issue.
-
6. Re: rich:tree with unselectable nodes
th.paulsen Jun 11, 2013 1:56 AM (in response to bleathem)"rf": {
"data": {
"oldSelection": [],
"newSelection": [
""
]
}
}
similar to the onselectionchange event: empty or null.
-
7. Re: rich:tree with unselectable nodes
bleathem Jun 11, 2013 2:02 AM (in response to th.paulsen)Are you familar with using the javascript debugger in your browser? If so, can you set a breakpoint here:
and see if you can figure out why the event.data is not as expected?
-
8. Re: rich:tree with unselectable nodes
th.paulsen Jun 11, 2013 2:27 AM (in response to bleathem)As far as I can see atm:
The values of the selections are ok in the tree.js, but they will not survive the deepest inner of jQuery.
It will take a bit longer to follow all the packing and upacking of the data
-
9. Re: rich:tree with unselectable nodes
th.paulsen Jun 11, 2013 3:15 AM (in response to bleathem)I'm wrong, newSelections isn't empty, my stringify-function shows visited nodes of the hierarchy as "" to avoid infinite loops;
Now I'm in the structure:
event.rf.data.newSelection[0].id.rf.component.id.rf.....;
-
10. Re: rich:tree with unselectable nodes
bleathem Jun 12, 2013 12:59 PM (in response to th.paulsen)So do you have this working now?
-
11. Re: rich:tree with unselectable nodes
th.paulsen Jun 14, 2013 1:17 AM (in response to bleathem)Yes.
function isSelectable(event)
{
try
{
var nid = event.rf.data.newSelection[0].id.id;
return $("div[id='"+nid+"']").find(".nodedisabled").length == 0;
}
catch (e)
{
// alert(e);
return false;
}
}