The problem was that I had replaced

RootPanel.get("linksPanel").add(linksPanelWidget);

with

Document.get().getElementById("linksPanel").appendChild
(linksPanelWidget.getElement());

because I was getting the error "A widget that has an existing parent
widget may not be added to the
detach list"

and this caused the click event to not reach my handler.
Putting back the RootPanel(...) code fixed it, and the 2.0 code is
after all correct:

Anchor loginLnk = new Anchor(msg.login());
loginLnk.addClickHandler(new ClickHandler(){
        @Override
        public void onClick(ClickEvent ev) {
                login();
        }
});


On Dec 31, 11:50 am, hbatista <[email protected]> wrote:
> I'm trying to upgrade a GWT 1.5 application into 2.0, and having
> problems getting hyperlink/anchor clicks to work as before.
>
> My 1.5 code is very simple, I'm creating a hyperlink and adding a
> click listener to it:
>
> Hyperlink loginLnk = new Hyperlink(msg.login(), "");
> loginLnk.addClickListener(new ClickListener(){
>    public void onClick(Widget sender) {
>         login();
>    }
>
> });
>
> Now, in 2.0, Hyperlink.addClickHandler is deprecated (and nothing
> happens when clicking it).
> If I replace it with an Anchor, I'm redirected to onModuleLoad when
> clicking it, and my handler doesn't run.
>
> What is the correct way to implement this behavior in GWT 2.0 ?

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.


Reply via email to