Daniel,
The DOM package was updated in 1.6 to deal with all those nasty $doc
assumptions, so you can create and manipulate the DOM in multiple
documents correctly (though it's still tricky, as you have to keep
track of which element belongs to which document). However, the Widget
library was not, as this is largely intractable without a complete
redesign. The problem is that you can't mix elements from different
documents (the browser will throw an exception if you're lucky, or
simply crash if you're not), and the Swing-style construction model
makes this exceedingly difficult (every widget would have to do
something weird like require a RootPanel (or simply a Document) to be
passed into to its ctor so that it could create its elements in the
right document; even then it would be very difficult to deal with
widgets being moved from one document to another).
The browser event model unfortunately doesn't provide any useful way
to aggregate events across frames/documents, either. The current GWT
event model (not part of the DOM module itself, yet) still assumes
that there is only one document at a time. It would be really nice to
have direct native event support in the DOM module itself at some
point, but there are some very difficult memory leak problems to be
solved before that will be feasible (i.e., if Element just had the
standard add/RemoveEventListener() methods, people would start
creating massive memory leaks).
I don't know the details of your application, but my inclination would
be to do as you suggest in the last paragraph and load separate
"instances" of the application into each iframe if you're going to be
doing significant UI within them. You could also try and manipulate
the iframes' DOMs directly, but you'd have to handle events with JSNI
methods, and you'd have to be very careful about leaks.
Cheers,
joel.
On May 7, 3:51 pm, DanG wrote:
> Can someone explain the way that GWT deals with iframes in this
> regard.
> If I want to create my own widgets or for that matter, use other
> widgets in an iframe.
>
> The situation is that I have cached versions of arbitrary webpages
> loaded into iframes (to get around the iframe domain problem)
> and then I want my code to annotate these pages in some fashion,
> ideally using floating GWT widgets.
>
> I would expect to do something like this.
>
> Document doc = iframe.getFrameDocument(); //wraps up the Document of
> an iframe using managed iframe from gwt-ext for now but thinking of
> doing this myself later and giving up on ext.
> BodyElement body = doc.getBody();
> Element div = DOM.createDiv();
> body.appendChild(div);
> div.setId("id123");
> RootPanel panel = RootPanel.get("id123");
> //or better would be RootPanel panel = RootPanel.get(div); //but this
> is not a public method.
> panel.add(firstWidgetOfMany)
>
> But because RootPanel uses Document.get().getElementById(id).cast()
> to find the element AND (shock horror) Document.get() assumes there is
> only ever one document for a gwt application I don't understand how
> one could tie up the elements in the frame to widgets in GWT without
> completely rewriting RootPanel and possibly other classes.
>
> I also want to ask what the potential pitfalls with this scenario are
> and the GWT event model.
> When I create widgets and parent/register them to existing widgets,
> will the events that the elements raise find their way back to the GWT
> widgets if the elements exist in the iframe?
>
> Am I thinking about this incorrectly? Is it better to create a new
> 'instance' of GWT inside the iframe and then try and get the parent
> and child instances talking together (i imagine this could also cause
> problems)? Or is it simply not worth using GWT widget infrastructure
> and build my own infrastructure based on DOM elements for this
> scenario (a real pity)?
>
> Thanx, Daniel.
--~--~-~--~~~---~--~~
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-Toolkit@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
-~--~~~~--~~--~--~---