Wednesday, October 26, 2016

Re: Setting a variable in the window namespace

Are you trying to store or to call. Your initial question was about storing but your update is about calling function f,,,

   .bill

On Wed, Oct 26, 2016 at 7:47 PM, Paul Mazzuca <paul.j.mazzuca@gmail.com> wrote:
Update:  I was able to sort of figure it out, but still had to use a bit of JSNI. Thought I would share the solution below.   As background I was trying to store a function in the window namespace.


@JsFunction

interface MyFunction {

     void run(String x);

}


//maybe another way to get the window without JSNI, but good enough for me

public native MyWindow get() /*-{

   return $wnd;

}-*/;


@JsType(isNative = true)

public static class MyWindow {

    @JsProperty

    public MyFunction f;

}


Then, in javascript I can now call


window.f("some string");




On Tuesday, October 25, 2016 at 4:42:21 PM UTC-7, Paul Mazzuca wrote:
Is there an equivalent way of using JSInterop to achieve the JavaScript functionality of   window.foo = 'someval'?


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.



--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment