preview in case of iframe

65 views
Skip to first unread message

bhomass

unread,
Jul 1, 2012, 3:45:07 AM7/1/12
to Google Web Toolkit
I have been struggling with this for the whole day and can't crack the
nut.

I know how things work when you call
Event.addNativePreviewHandler(handler) to trigger event preview. The
preview is meant to be a global concept so that anything events
happening else where would get previewed. However, if an iframe is
added into the picture, the previewer is apparently not so global.
things happening inside the iframe does not trigger DOM.preview(evt),
and therefore does not get previewed.

I suppose this makes sense, that the iframe has an independent DOM
structure from the parent. Does any one know of a way to bridge the
two so that the two parts together still behaves truly in a GLOBAL
way?

gpike

unread,
Jul 2, 2012, 2:47:17 PM7/2/12
to google-we...@googlegroups.com
  The document inside you iFrame is a completely separate document and can be from a different domain as well so won't get any events just like you don't get events from other browser tabs. However you could communicate across the boundary by defining your own api's. What I mean is you can add Javascript methods to the containing document and call them from the child using top.<insert method name>. 

  What I've done in the past is create 2 entry points (and modules), essentially two GWT apps,  one for the parent window and the other for the child window. Using JSNI expose a well know method name on the parent that can be called. It can be a pain but we had an app that could be hosted in another app using a iFrame and could have hot key support for both passing key events to the parent. By the way this only works when both apps are from the same domain.

Good Luck,
 
Gordon Pike

bhomass

unread,
Jul 2, 2012, 7:59:00 PM7/2/12
to google-we...@googlegroups.com
thanks, I figured as much. The two documents are independent DOM structures and while the preview is "global", it is only global within one DOM structure.

I got what I want w/o preview, using addDomHandler.

as long as you have the handle to components in both frames, this works quite fine.

Reply all
Reply to author
Forward
0 new messages