Hm. IE doesn't support setAttribute to set event listeners, and GWT
prides itself on not accommodating different browsers for things like
this,

You're best off writing your own.
Perhaps something like this?

        public void onModuleLoad() {
                final Label l = new Label("This is a label");
                setProperty(l.getElement(),"onclick", "alert('hello');");
                RootPanel.get().add(l);
        }

        private native void setProperty(Element e, String property, String
value) /*-{
                var event = null;
                value = "event = function() { " + value + "};";
                eval(value);
                e[property] = event;
        }-*/;


~
D.

On Oct 24, 4:42 pm, Tomer <tom...@gmail.com> wrote:
> Yes, this is exactly what I expected.
> I'm using GWT 1.7.1
>
> Following your response, I went over to WinXP (SP3), installed a fresh
> copy of eclipse and of the Google plugin, created a new GWT project
> and replaced the entire contents of the entry module class with the
> code listed above. Still doesn't work - when I click the label,
> nothing happens - not in hosted mode and not in web mode. (and still
> works in the other browsers)
>
> Regards,
> Tomer
>
> On Oct 24, 3:23 am, dougx <douglas.lin...@gmail.com> wrote:
>
>
>
> > O_o can you be more specific? This works fine for me in ie6 / ie7 /
> > ie8 / ie8 compatability mode...
>
> > Well... which is to say, I got a popup saying "Hello".
> > What were you expecting to happen?
>
> > public class Testing implements EntryPoint {
> >     static {
> >         exportJSNI();
> >     }
> >     public void onModuleLoad() {
> >         runJSNI();
> >     }
> >    private static native void runJSNI() /*-{
> >       $wnd.run();
> >    }-*/;
> >    private static native void exportJSNI() /*-{
> >         $wnd.run = function() {
> >                 alert("hello");
> >         };
> >     }-*/;
>
> > }
>
> > ~
> > D.
>
> > On Oct 23, 11:38 pm, Tomer <tom...@gmail.com> wrote:
>
> > > Hi,
> > > I've got the following piece of code. Works perfectly in every browser
> > > other than IE.
> > > What's going on?
>
> > > package test.client;
>
> > > import com.google.gwt.core.client.EntryPoint;
> > > import com.google.gwt.user.client.ui.Label;
> > > import com.google.gwt.user.client.ui.RootPanel;
>
> > > public class Iejsni implements EntryPoint {
>
> > >         static {
> > >                 exportJSNI();
> > >         }
>
> > >         public void onModuleLoad() {
> > >                 final Label label = new Label("click me");
> > >                 label.getElement().setAttribute("onclick", "run()");
> > >                 RootPanel.get().add(label);
> > >         }
>
> > >         private static native void exportJSNI() /*-{
> > >                 $wnd.run = function() {
> > >                         alert("hello");
> > >                 };
> > >         }-*/;
>
> > > }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to