You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Penn <du...@yahoo.com> on 2009/02/04 20:45:42 UTC
How to resolve tree issue?
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.TagGroup@499f7d[name=Vertical]
com.abc.core.model.Tag@11f1d25[name=Retail]
com.abc.core.model.Tag@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
--
View this message in context: http://www.nabble.com/How-to-resolve-tree-issue--tp21838037p21838037.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to resolve tree issue?
Posted by Ernesto Reinaldo Barreiro <er...@fcc.es>.
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.TagGroup@499f7d[name=Vertical]
> com.abc.core.model.Tag@11f1d25[name=Retail]
> com.abc.core.model.Tag@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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to resolve tree issue?
Posted by nav <na...@gmail.com>.
Does your model have getName() , if so why dont you try with that instead of
.toString().
//N
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.TagGroup@499f7d[name=Vertical]
> com.abc.core.model.Tag@11f1d25[name=Retail]
> com.abc.core.model.Tag@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
>
>
--
View this message in context: http://www.nabble.com/How-to-resolve-tree-issue--tp21838037p21857978.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org