I haven't used tree from inmethod myself but I would bet that what you
see is the result of DetachableTagGroupModel(tg.toString())... So
either override your toString or change DetachableTagGroupModel to
return what you want... (maybe look at the implementation to see how the
node's text is produced?)
About recovering model object:
if(node instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node;
Object userObject = treeNode.getUserObject();
....
}
In your case I guess this object will be a String (because of new
DetachableTagGroupModel(tg.toString()))
Regards,
Ernesto
Penn wrote:
Hi all,
I am working with wicket tree based on the inmethod tree example.I have just
2 level tree with taggroup and tags. I have issue in just displaying the
name, rather I get a whole object, The code is below
protected TreeModel createTreeModel() {
TreeModel model = null;
final List list = getGenericTagGroupService().getAll();
final DefaultMutableTreeNode rootNode = new
DefaultMutableTreeNode(new
ModelBean("ROOT"));
add(rootNode, list);
model = new DefaultTreeModel(rootNode);
return model;
}
private void add(final DefaultMutableTreeNode parent, final List sub) {
for (final Iterator i = sub.iterator(); i.hasNext();) {
final TagGroup tg = (TagGroup) i.next();
final DefaultMutableTreeNode child = new
DefaultMutableTreeNode(new
DetachableTagGroupModel(tg.toString()));
parent.add(child);
final List tags = new ArrayList(tg.getTags());
for (final Iterator j = tags.iterator(); j.hasNext();) {
final Tag t = (Tag) j.next();
child.add(new DefaultMutableTreeNode(new
DetachableTagModel(t.toString())));
}
}
}
I get the output like this,
com.abc.core.model.taggr...@499f7d[name=vertical]
com.abc.core.model....@11f1d25[name=retail]
com.abc.core.model....@1df5c7[name=financial]
what i need is this,
Vertical
Retail
Financial
Also how to get back the model object again onClick,
protected void onNodeLinkClicked(final TreeNode node, final BaseTree tree1,
final AjaxRequestTarget target) {
super.onNodeLinkClicked(node, tree1, target);
// setResponsePage();
}
Thanks in advance
~Penn
*************************************************************
Este correo ha sido procesado por el antivirus del Grupo FCC.
*************************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]