Re: addWindowClosingHandler firing when frame loads in IE
Bingo again, Tom. In fact, doing this I don't even have to bother with History. I just grab the value href, parse it, and call my pop- up. I don't want (or need) it in the history change. On Jan 8, 1:52 pm, Thomas Broyer wrote: > ... > Ah, OK, so in your case, retrieving the NativeEvent's EventTarget, cast > ()ing into an AnchorElement (well, first verifying that it *is* an "A" > element by checking its getTagName(), and walking the tree up until > the HTML widget's getElement() or an "A" element is found) then > calling AnchorElement#getHref() should give you what you want. Then > get the indexOf("#") and then the substring(hashIndex) to pass it to > History.newItem(...). > > You'll find similar code walking up a DOM tree in > HTMLTable#getEventCellTarget (or a similar named private/protected > method, this is from memory), in this case it's looking for "TD" > elements. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: addWindowClosingHandler firing when frame loads in IE
On Jan 8, 7:27 pm, Thad wrote: > 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 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). Ah, OK, so in your case, retrieving the NativeEvent's EventTarget, cast ()ing into an AnchorElement (well, first verifying that it *is* an "A" element by checking its getTagName(), and walking the tree up until the HTML widget's getElement() or an "A" element is found) then calling AnchorElement#getHref() should give you what you want. Then get the indexOf("#") and then the substring(hashIndex) to pass it to History.newItem(...). You'll find similar code walking up a DOM tree in HTMLTable#getEventCellTarget (or a similar named private/protected method, this is from memory), in this case it's looking for "TD" elements. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: addWindowClosingHandler firing when frame loads in IE
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 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 wrote: > On Jan 8, 12:29 pm, John Patterson 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 google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: addWindowClosingHandler firing when frame loads in IE
On Jan 8, 12:29 pm, John Patterson 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 google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: addWindowClosingHandler firing when frame loads in IE
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. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: addWindowClosingHandler firing when frame loads in IE
On Jan 8, 8:54 am, jd wrote: > I have found that I could avoid the problem by using Button's (or > probably other widgets) instead of Anchor widgets for my internal > navigation. Perhaps it is due to the default href "javascript:;" ? > Maybe IE7/8 does not recognise this as an internal link. 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). -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: addWindowClosingHandler firing when frame loads in IE
I have found that I could avoid the problem by using Button's (or probably other widgets) instead of Anchor widgets for my internal navigation. Perhaps it is due to the default href "javascript:;" ? Maybe IE7/8 does not recognise this as an internal link. On Jan 8, 12:15 pm, jd wrote: > Hi, > > I use Window.addWindowClosingHandler() to warn the user when they are > about to leave my app and loose their current state. It works in > Chrome and Firefox but in IE the handler is fired every time my app > calls History.add(). Im not sure if its related to the fact that I > have a Frame on the page. > > Any suggestions? -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
addWindowClosingHandler firing when frame loads in IE
Hi, I use Window.addWindowClosingHandler() to warn the user when they are about to leave my app and loose their current state. It works in Chrome and Firefox but in IE the handler is fired every time my app calls History.add(). Im not sure if its related to the fact that I have a Frame on the page. Any suggestions? -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.