Crazyness

3 views
Skip to first unread message

Marcos Araujo Sobrinho

unread,
Aug 15, 2006, 4:30:37 PM8/15/06
to google-we...@googlegroups.com
Hi!
 
Anybody know a way to:
 - interact with an widget, using JSNI?
 - interact with an widget, that is on another *frame*?
 
I´m trying to do something like this, without success:
public native static void setFramedWidget(String widgetName, Label widget) /*-{
 ...
 ...
  widget.setLabel("Tô no JS!");
 }-*/;
}
 
Any ideas?
 
Thanks!
 
Marcos

Vivian

unread,
Aug 16, 2006, 2:49:36 AM8/16/06
to Google Web Toolkit

Hi Marcos,
When calling Java from JavaScript, one must use a special JSNI
syntax. See
http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.JavaScriptNativeInterface.JavaFromJavaScript.html

To make your example work, you would write


widget.@com.google.gwt.user.client.ui.Label::setText(Ljava/lang/String;)("Tô
no JS!");

-Vivian

Marcos Araujo Sobrinho

unread,
Aug 16, 2006, 11:39:00 AM8/16/06
to Google-We...@googlegroups.com
it´s working :)

i will read a little bit more about jsni. thanks!

marcos

-----Mensagem original-----
De: Google-We...@googlegroups.com
[mailto:Google-We...@googlegroups.com]Em nome de Vivian
Enviada em: quarta-feira, 16 de agosto de 2006 03:50
Para: Google Web Toolkit
Assunto: Re: Crazyness

Marcos Araujo Sobrinho

unread,
Aug 16, 2006, 11:59:58 AM8/16/06
to Google-We...@googlegroups.com
Hi Vivian

There is any way to return my label object from JSNI back to Java?

For example:
public native static Label getLabel(String frameName, String widgetName) /*-{
widgetList = $wnd.parent.frames[frameName].framedWidgets;
for(x=0; x<widgetList.length; x++) {
if (widgetList[x].name == widgetName) {
return widgetList[x].object.@com.google.gwt.user.client.ui;
break;
}
}
alert("ERROR: Widget "+widgetName+" not found on frame "+frameName+".");
return false;
}-*/;

My problem: i have 2 GWT applications, in 2 frames, and I´m trying to update widgets from one frame to another.

Any idea? Is it possible at all?

Thanks!!

Marcos

-----Mensagem original-----
De: Google-We...@googlegroups.com
[mailto:Google-We...@googlegroups.com]Em nome de Vivian
Enviada em: quarta-feira, 16 de agosto de 2006 03:50
Para: Google Web Toolkit
Assunto: Re: Crazyness

Reply all
Reply to author
Forward
0 new messages