The JavaDoc says to use FocusWidget.addClickHandle. Why does the Hyperlink need to use this FocusWidget? Why can a Hyperlink not use a ClickHandler but a GWT Button and Anchor can?
I'm not sure how to use it? Does anyone have an example?
Deprecated. Use FocusWidget.addClickHandler(com.google.gwt.event.dom.client.ClickHandler) instead and call History.newItem from the handler if you need to process the click before the history token is set.
Here's my current code that takes a Hyperlink named hyperLink and adds a ClickHandler. How would I recode this to use FocusWidget.addClickHandler(ClickHandler) ?
Interesting, but I read a comment somewhere that said to someone "maybe you should be using a GWT Anchor instead of a GWT Hyperlink." The hyperlink was not only giving me deprecation messages, but it also was taking me to a wrong screen, although it was correctly doing CardDeck transitions, so when you went back to the page you were supposed to be at, it was being displayed properly - just buried by another screen. Anyways, I said to myself "Self, maybe you should be using a GWT Anchor?"
When I used the Anchor, my ugly deprecation messages about the ClickHandler went away:
Now to see if it provides the behavior I'm looking for?
In an attempt to hijack my own thread, I am now wondering what is the difference between a GWT Anchor vs Hyperlink? Hmmm...
Now I'm going to shove a button in there in addition to the Hyperlink and Anchor.
I think it's my History that's causing the problem. So, this is what the compiler had to say about that:
java.lang.AssertionError: targetHistoryToken must not be null, consider using Anchor instead
So, this starts to answer my question about the difference between an anchor and a hyperlink. I guess an anchor doesn't need to create a history token, where a HyperLink must?
GWT Anchor JavaDoc
GWT Hyperlink JavaDoc
Hyperlink: A widget that serves as an "internal" hyperlink. That is, it is a link to another state of the running application. When clicked, it will create a new history frame using History.newItem(java.lang.String), but without reloading the page.
Being a true hyperlink, it is also possible for the user to "right-click, open link in new window", which will cause the application to be loaded in a new window at the state specified by the hyperlink.
It does look like the improper handling of my History token was to blame for my quirkiness. Both the Button and Anchor without a history token provided the behavior I wanted:
So, I managed to fix the application by avoiding the original problem, which is really just an issue of how to properly use the GWT API, and more to the point, how to program Java. So, the question remains, does anyone have a sample of code that uses the FocusWidget.addClickHandler to add an event handler to a GWT Hyperlink, since we can't use the deprecated ClickHandler???
BTW, it's been fun chatting with myself this Saturday afternoon. What a great thread: images, pictures, code, runtime bugs, compiler errors, hyperlinks, and all esoterically assembled without an answer to the original conundrum? A work of art to be admired by the romantics, if I do say so myself.
Cameron Wallace McKenzie wrote: BTW, it's been fun chatting with myself this Saturday afternoon. What a great thread: images, pictures, code, runtime bugs, compiler errors, hyperlinks, and all esoterically assembled without an answer to the original conundrum? A work of art to be admired by the romantics, if I do say so myself.
Very interesting man,
I confess if i had updated myself to gwt2.0, i would have definitely helped you in this issue....
All that i know is that in GWT 1.5,
A hyperlink triggers an history event compulsorily, The only way i could circumnavigate this was by using an HTML widget containing "<a href='something'>text</a>"
These do not generate history events.