On 15 דצמבר, 13:32, grue <michael.gruetz...@googlemail.com> wrote:
> Hi,
>
> I have splited my applications into several modules which I have
> embedded in a single HTML page. To enable the modules to communicate
> between each other I have implemented a simple event mechanism. If a
> module wants to "listen" to an event it registers a handler for it
> like this:
>
> private native void registerEventListener(ModuleB instance, String
> eventName) /*-{
>
>                 if($wnd.myEvents == null) {
>                         $wnd.myEvents = {};
>                 }
>
>                 $wnd.myEvents[eventName] = function(event)
> {     instan...@com.mypackage.moduletest.client.moduleb::setLabel
> (Ljava/lang/String;)(event); };
>         }-*/;
>
> Now, when another modules fires an event the Java method setLabel() is
> called. This works pretty good so far.
> Anyway, I'd like to make the mechanism more dynamic by providing the
> name of the Java method to call dynamically.
> Unfortunately I'm stuck here.
> What I've tried is to use the eval() function to dynamically call the
> method. The eval() statement looks similar like this:
> eval("instance.@" + className + "::" + methodName + "(Ljava/lang/
> String;)(event)"); where className and methodName are provided as
> arguments to the JSNI method. I have learned that this must fail since
> neither className nor methodName are in the execution context of the
> eval() function.
>
> Is there any other way to achieve the desired behaviour?
> Any hint is appreciated.
>
> Best regards,
> Michael

hi michael,

If you want to transfer data between the modules you can load the data
to session and read data from session
load data to session:
 this.getThreadLocalRequest().getSession().setAttribute("stringVal",
stringVal);
read data from session:
String stringVal = this.getThreadLocalRequest().getSession
().getAttribute("stringVal").toString();

hope I helped

nahum.


--

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-tool...@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