Make sure you modify the following native method to point to your own
package structure:
public native void setMyOnload(JavaScriptObject elm, MyNamedFrame
frame)/*-{
elm.myonload = function(event){
[email protected]::onload(Lcom/
google/gwt/user/client/Event;)(event);
};
}-*/;
You need to modify "com.skystrider.subtabs.client.gwtUtils" to the
package structure location that you have MyNamedFrame stored.
On May 21, 12:43 pm, mmoossen <[email protected]> wrote:
> hi sky!
>
> that looks pretty much like our implementation...;)
> this is the problem of such a big toolkit likeGWT, there are too many
> 'features' (like widgets, rpc, jre emulation, java-to-js compilation,
> the new data driven widgets and so on) which is great for a fast start
> and even enough for many applications, but as soon as you get
> creative, you have to start doing things by yourself, which is inmy
> expirience really hard withGWTsince many, many (far too much)
> methods and classes are private or final, so it is really hard to
> extend the provided stuff, so at the end you finish hackingGWTand
> building your own framework on top of the toolkit based on the core
> feature, java-to-js compilation, which could be the idea.of the
> developers, i do not know...
>
> continue the good work!
>
> regards
> Michael
>
> On May 21, 9:04 am, Sky <[email protected]> wrote:
>
>
>
>
>
> > package com.skystrider.subtabs.client.gwtUtils;
>
> > import java.util.ArrayList;
>
> > import com.google.gwt.core.client.GWT;
> > import com.google.gwt.core.client.JavaScriptObject;
> > import com.google.gwt.dom.client.IFrameElement;
> > import com.google.gwt.user.client.DOM;
> > import com.google.gwt.user.client.Element;
> > import com.google.gwt.user.client.Event;
> > import com.google.gwt.user.client.ui.Frame;
>
> > /**
> > * A {...@link com.google.gwt.user.client.ui.Frame} that has a 'name'
> > associated
> > * with it. This allows theframeto be the target of a
> > * {...@link com.google.gwt.user.client.ui.FormPanel}
> > *
> > * <h3>CSS Style Rules</h3>
> > * <ul class='css'>
> > * <li>.gwt-Frame{ }</li>
> > * </ul>
> > */
> > public class MyNamedFrame extendsFrame{
>
> > private ArrayList<LoadHandler> loadHandlers = null;
>
> > // Used inside JSNI, so please don't delete this field just
> > because
> > // your compiler or IDE says it's unused.
> > @SuppressWarnings("unused")
> > private static JavaScriptObject PATTERN_NAME;
>
> > static {
> > if (GWT.isClient()) {
> > initStatics();
> > }
> > }
>
> > /**
> > * Creates an HTML IFRAME element with a src andname.
> > *
> > * @param src the src of theframe
> > * @paramnamethenameof theframe, which must contain at least
> > one
> > * non-whitespace character and must not contain reserved
> > HTML markup
> > * characters such as '<code><</code>', '<code>></
> > code>',
> > * or '<code>&</code>'
> > * @return the newly-created element
> > * @throws IllegalArgumentException if the suppliednameis not
> > allowed
> > */
> > private static IFrameElement createIFrame(String src, Stringname)
> > {
> > if (name== null || !isValidName(name.trim())) {
> > throw new IllegalArgumentException(
> > "expecting one or more non-whitespace chars with no '<',
> > '>', or '&'");
> > }
>
> > // Use innerHTML to implicitly create the <iframe>. This is
> > necessary
> > // because most browsers will not respect a dynamically-set
> > iframename.
> > Element div = DOM.createDiv();
>
> > String onload = "onload=\"if(!event){event = window.event;}
> > this.myonload(event);\"";
>
> > div.setInnerHTML("<iframe src=\"" + src + "\"name='" +name+ "'
> > " + onload + ">");
> > return div.getFirstChild().cast();
> > }
>
> > private static native void initStatics() /*-{
> > @com.google.gwt.user.client.ui.NamedFrame::PATTERN_NAME =
> > /^[^<>&
> > \'\"]+$/;
> > }-*/;
>
> > /**
> > * @paramnamethe specifiedframenameto be checked
> > * @return <code>true</code> if thenameis valid, <code>false</
> > code> if
> > * not
> > */
> > private static native boolean isValidName(Stringname) /*-{
> > return
> > @com.google.gwt.user.client.ui.NamedFrame::PATTERN_NAME.test(name);
> > }-*/;
>
> > /**
> > * Constructs aframewith the givenname.
> > *
> > * @paramnamethenameof theframe, which must contain at least
> > one
> > * non-whitespace character and must not contain reserved
> > HTML markup
> > * characters such as '<code><</code>', '<code>></
> > code>',
> > * or '<code>&</code>'
> > *
> > * @throws IllegalArgumentException if the suppliednameis not
> > allowed
> > */
> > public MyNamedFrame(Stringname) {
> > // Setting a src prevents mixed-content warnings.
> >
> > //http://weblogs.asp.net/bleroy/archive/2005/08/09/how-to-put-a-div-ove...
> > super(createIFrame("javascript:''",name));
> > setStyleName("gwt-Frame");
> > setMyOnload(this.getElement().cast(), this);
> > }
>
> > /**
> > * Gets thenameassociated with thisframe.
> > *
> > * @return theframe'sname
> > */
> > public String getName() {
> > return DOM.getElementProperty(getElement(), "name");
> > }
>
> > public void addLoadHandler(LoadHandler handler) {
> > if(loadHandlers == null){
> > loadHandlers = new ArrayList<LoadHandler>();
> > }
> > loadHandlers.add(handler);
> > }
>
> > public interface LoadHandler {
> > void onLoad(Event event);
> > }
>
> > public native void setMyOnload(JavaScriptObject elm, MyNamedFrame
> >frame)/*-{
>
> > elm.myonload = function(event){
>
> > [email protected]::onload(Lcom/
> > google/gwt/user/client/Event;)(event);
> > };
> > }-*/;
>
> > public void onload(Event event)
> > {
> > for (LoadHandler handler : loadHandlers) {
> > handler.onLoad(event);
> > }
> > }
>
> > }
>
> > On May 20, 12:13 am, Sky <[email protected]> wrote:
>
> > > Just in case you ever wanted to have a handler for the <iframe>'s
> > > onload event:
>
> > > import com.google.gwt.event.dom.client.HasLoadHandlers;
> > > import com.google.gwt.event.dom.client.LoadEvent;
> > > import com.google.gwt.event.dom.client.LoadHandler;
> > > import com.google.gwt.event.shared.HandlerRegistration;
> > > import com.google.gwt.user.client.ui.NamedFrame;
>
> > > public classMyNamedFrameextendsNamedFrameimplements
> > > HasLoadHandlers {
>
> > > publicMyNamedFrame(Stringname) {
> > > super(name);
> > > }
>
> > > @Override
> > > public HandlerRegistration addLoadHandler(LoadHandler handler) {
> > > return addDomHandler(handler, LoadEvent.getType());
> > > }
>
> > > }
>
> > > --
> > > 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
> > > athttp://groups.google.com/group/google-web-toolkit?hl=en.
>
> > --
> > 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
> > athttp://groups.google.com/group/google-web-toolkit?hl=en.
>
> --
> 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
> athttp://groups.google.com/group/google-web-toolkit?hl=en.
--
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.