PDA

View Full Version : LinkButton



brendand
9 May 2009, 3:35 AM
In asp.net, there is a control called a LinkButton. It looks like a link but behaves like a button. Is there a similar control is gxt, or a way to reproduce it.

I'd like to have some code like this


LinkButton logout = new LinkButton("Logout");
logout.addListener(Events.OnClick, new Listener<ComponentEvent>() {
@Override
public void handleEvent(ComponentEvent be) {
...
}
});


I've tried with LabelField and Text, but I can seem to make either of them aware of when the user clicks on the link.

My code so far is


Text logout = new Text("Logout");
logout.setTagName("span");
logout.setStyleAttribute("cursor","pointer");
logout.addListener(Events.OnClick, new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
Info.display("click", "moo");
}
});
RootPanel.get().add(logout);

sven
9 May 2009, 3:40 AM
You need to sink the click event.