Tom, is there any way to capture the value of an anchor's href in my
GWT code?

My situation is that my application receives String from an RPC call
that is bounded by the <pre> tag and contains any number of anchors.
I display this in a HTML object in a SimplePanel in a ScollPanel for
the user to read.  Clicking on one of the anchors is supposed to
request some additional info from the server about the text
highlighted by that anchor.  (The text file itself is from a text
search database.  The anchors mark items in the document that cause
the document to be a search hit.)

The href's I've been creating on the server point back into my
application with a history token that makes the server call and pops
up a dialog box.  This works fine in Firefox and Safari, but on IE I
have jd's problem--my application reloads.

Calling preventDefault() inside the click handler for my HTML object
stops the call, but I need the data in the href to do anything useful
(like make my next server call and show a pop-up at NativeEvent client
x and y).

Thanks

On Jan 8, 9:30 am, Thomas Broyer <[email protected]> wrote:
> On Jan 8, 12:29 pm, John Patterson <[email protected]> wrote:
>
> > On 8 Jan 2010, at 16:22, Thomas Broyer wrote:
>
> > > Use Hyperlink or InlineHyperlink widgets for "internal
> > > navigation" (unless you also want ClickHandlers, in which case Anchor
> > > is fine, calling History.newItem() in a ClickHandler, but do not
> > > forget to ClickEvent#preventDefault() // this is more or less what
> > > Hyperlink/InlineHyperlink widgets do).
>
> > Using Anchors caused onWindowClosing() to be called in IE7/8 so I  
> > could not use them.  Using Button has solved this so far although I  
> > have a lot of default CSS to override.  I just tested with Hyperlink  
> > as you suggested and this also works fine.  Perhaps the difference is  
> > that it uses "#" as the href rather than "javascript:;" so IE  
> > recognises this as an internal link.
>
> No, the reason is that it ClickEvent#preventDefault() in a
> ClickHandler. If you do the same with an Anchor in your ClickHandler,
> it'll work too.
>
> Hyperlink/InlineHyperlink though has some differences with Anchor that
> make it worth it:
>  - the link's href="" is the history token the Hyperlink targets, so
> you can right-click -> open in new window (or tab), or ctrl+click or
> middle-click or whatever to open the link in another window/tab; and
> you can of course also drag'n'drop the link into another application
> to have a direct URL to the "page" targeted by the Hyperlink
>  - the ClickHandler only ClickEvent#preventDefault() under some
> conditions, so that the right-click, middle-click and ctrl+click work
> OK (and the conditions are different depending on the browser, thanks
> to GWT's "deferred binding" feature)
>
> If you don't want this behavior, then a Button or Label/InlineLabel
> would be more appropriate than Anchor or Hyperlink/InlineHyperlink.
-- 
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