This should be a very simple question. I have a richfaces tree that is created using JSF. When the user clicks on node, I want to run a javascript function. No more, no less. No redirects, no resubmission, no retry, no Ajax. Just old javascript.
I saw the onselected attribute of the tree, and it really runs the Javascript method. But, of course, I want to know what node clicked on.
That's what i still have
<head>
<script type="text/javascript">
function documentClicked(nodeRef)
{
alert("Node is "+nodeRef);
}
</script>
</head>
<rich:tree switchType="client" value="#{ajaxDocumentTree.rootNode}"
var="document" onselected="documentClicked()" >
<rich:treeNode iconLeaf="../images/tree/doc.gif"
icon="../images/tree/doc.gif">
<h:outputText value="#{document.friendlyName}" />
</rich:treeNode>
But this does not work, because nodeRef is undefined. I expected node to be the first argument of the callback, but this is not the case.
So the question is:
How do I run a Javascript function with the selected node from the interface tree?