Yes, you are correct. If you had this before:
Hyperlink link = new Hyperlink("text");
link.addClickHandler(...);
you should change it to this:
Anchor link = new Anchor("text");
link.addClickHandler(...);
However, Hyperlink is block-level whereas Anchor is inline. Anchor is
actually more analogous to InlineHyperlink (subclass of Hyperlink).
You should keep that in mind insofar as keeping your layout consistent
after making the switch.
On Feb 20, 10:15 pm, Tapas Adhikary <[email protected]> wrote:
> So does it mean , I need to change the HyperLink to anchor wherever I need a
> link functionality but doesn't need a history support ? Can anybody provide
> some suggestion / example code ?
>
> Thanks,
> -Tapas
>
> On Sat, Feb 20, 2010 at 11:18 PM, Zak <[email protected]> wrote:
> > Hi Tapas-
>
> > Check out this issue for the reasoning behind the deprecation of
> > Hyperlink.addClickHandler:
>
> >http://code.google.com/p/google-web-toolkit/issues/detail?id=1960
>
> > from tamplinjohn's comment on that thread:
>
> > "I also think that allowing click listeners/handlers on Hyperlink is
> > part of the
> > reason for the confusion -- if its goal is to manipulate the history
> > state, there
> > isn't any reason for adding a listener on the click, but you should
> > instead add a
> > history listener so that function works the same way whether activated
> > by a click, a
> > back button, or loading from a bookmark. If for some reason you do
> > really need a
> > click handler, then it can still be done by using Anchor and calling
> > History.newItem
> > from its listener."
>
> > On Feb 19, 2:18 pm, Tapas Adhikary <[email protected]> wrote:
> > > I have upgraded my project to GWT 2.0, and my hyperlinks keeps getting
> > > the wornings for using the deprecated ClickHandler.
>
> > > The JavaDoc says to use FocusWidget.addClickHandle. Why does the
> > > Hyperlink need to use this FocusWidget? How should I use it ? Why can
> > > a Hyperlink not use a ClickHandler but a GWT Button and Anchor can?
> > > What is the logic behind it ?
>
> > > I'm not sure how to use it? Does anyone have an example? Please share.
>
> > > Thanks,
> > > -Tapas
>
> > --
> > 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]<google-web-toolkit%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en.
--
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.