Adding Link to Tree , How ?

Hi , i wanted to add some Links to Tree but it seems it can only add String.
I want to use Tree as a navigation.

Here is my code that extends Tree but when i add this Tree to my app , i see this:
http://imageshack.us/photo/my-images/39/linkzh.png/

Whats wrong?
How can i add custom objects?

package com.test;

import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.ItemClickEvent.ItemClickListener;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.Link;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Tree;
import com.vaadin.ui.VerticalLayout;

public class ToCTree extends Tree implements ItemClickListener {

public ToCTree() {
	super("");
	
	final Object[][]

planets = new Object
{
new Object{“Mercury”},
new Object{“Venus”},
new Object{“Earth”, “The Moon”},
new Object{“Mars”, “Phobos”, “Deimos”},
new Object{“Jupiter”, “Io”, “Europa”, “Ganymedes”,
“Callisto”},
new Object{“Saturn”, “Titan”, “Tethys”, “Dione”,
“Rhea”, “Iapetus”},
new Object{“Uranus”, “Miranda”, “Ariel”, “Umbriel”,
“Titania”, “Oberon”},
new Object{“Neptune”, “Triton”, “Proteus”, “Nereid”,
“Larissa”}};

	/* Add planets as root items in the tree. */
	for (int i=0; i<planets.length; i++) {
	    Link planet = new Link((String) (planets[i]

[0]
),new ExternalResource(“http://www.l2wolf.com”) );
planet.getDescription( );
addItem(planet);

	    if (planets[i]

.length == 1) {
// The planet has no moons so make it a leaf.
setChildrenAllowed(planet, false);
} else {
// Add children (moons) under the planets.
for (int j=1; j<planets[i]
.length; j++) {
String moon = (String) planets[i]
[j]
;

	            // Add the item as a regular item.
	            addItem(moon);
	            
	            // Set it to be a child.
	            setParent(moon, planet);
	            
	            // Make the moons look like leaves.
	            setChildrenAllowed(moon, false);
	        }
	        // Expand the subtree.
	        expandItemsRecursively(planet);
	    }
	}
	
	addListener(  (ItemClickListener)this);
}

@Override
public void itemClick(ItemClickEvent event) {
	// TODO Auto-generated method stub
	Object src = event.getSource();
	System.out.println(src.toString());
	System.out.println(event.getButtonName());
}

}

You can only add text to a tree. Can’t you do the navigation that you need inside the itemClick method, or alternatively inside a ValueChangeListener? the method Window.open works pretty much the same way.

If you really need the tree and components inside it, then check out
ComponentTree in the Directory
.

Nice addon , but is it good for SEO?

When google bot enters my page , bot must dedect my ajax links.
Its giving directly links to bots?

Okay, maybe you need the Links in there then, if you want to have some kind of support for search engines. The Links
should
be enough for that. Search the forum around for posts regaring search engines, for example
this one
has some info regarding those.

Here’s a few other threads as well:


how to make vaadin app components searchable by search engines?


Rich web apps and search engines like a Google - indexing problems and tri

Okay that means ,
Inside ComponentTree i will add Link object for each item.
And my ajax page must start with “#!”

So my code will be SEO friendly.
Hope so :slight_smile: