junaidp
junaidp

Reputation: 11201

GWT:adding clickHandler on HyperLink

I am having this HyperLInk in my cellTable ,but its Clickhandler is not working

myHyperLInk.addClickHandler(new ClickHandler(){

  public void onClick(ClickEvent event) {
    Window.alert("test");

 }});

It displays a warning :

The method addClickHandler(ClickHandler) from the type Hyperlink is deprecated

When i click on the link, it simple go to the previous page from history. How can i simply say show a message dialog on pressing a hyperLink?

Upvotes: 0

Views: 4670

Answers (2)

Shivani
Shivani

Reputation: 1

Hyperlink link0 = new Hyperlink("link to foo","foo");
link0.addDomHandler(handler, ClickEvent.getType());


ClickHandler handler = new ClickHandler() {
    public void onClick(ClickEvent event) {
         Window.alert("test");
    }
};

Upvotes: 0

Ian Jacobs
Ian Jacobs

Reputation: 5501

I think what you want may be an anchor widget vs a hyperlink.

http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/gwt/user/client/ui/Anchor.html

Hyperlinks are usually used for working with the history.

Upvotes: 2

Related Questions