Kai Schubert-Altmann skrev:
Thanks a lot, Edvin.
I will try your answers to 2. and 3..
But I think, that overwriting the populateTreeItem method wouldn't help,
because i want to modify nodes of an existing tree, for example mark them
red if I click on them.
Any suggestions?
That's why you need to add an AbstractBehaviour to each item. The
onComponentTag() method will be run before the component is rendered, so
you can check the state of your userObject and add/remove classes using
the tag.put() approach :)
Also, you might look into onNodeLinkClicked() method of the tree, if you
want to perform actions when you click on an item. The
onNodeLinkClicked() gives you access to the AjaxRequestTarget, so you
can also execute arbitrary javascript code, like this:
protected void onNodeLinkClicked(AjaxRequestTarget target, TreeNode node) {
MyObject myObject = (MyObject) ((DefaultMutableTreeNode)
node).getUserObject();
if(myObject.getMyState())
target.appendJavascript("targetTheComponentWithAJavascriptMethod(" +
getId() + ");");
}
Either that, or you could change the state of the userObject in the
onNodeLinkClicked method and add it to the AjaxRequestTarget. Your
AbstractBehaviour will then take care of visualizing the new state of
the object for you :)
-- Edvin
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]