Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT JSNI - problem passing Strings

Tags:

gwt

jsni

I'm trying to provide some function hooks in my GWT project:

private TextBox hello = new TextBox();
private void helloMethod(String from) { hello.setText(from); }
private native void publish() /*-{
 $wnd.setText = $entry([email protected]::helloMethod(Ljava/lang/String;));
}-*/;

publish() being called in onModuleLoad(). But this doesn't work, providing no feedback as to why in the dev console. I've also tried:

private native void publish() /*-{
 $wnd.setText = function(from) {
  alert(from);
  [email protected]::helloMethod(Ljava/lang/String;)(from);
 }
}-*/;

which will toss a java.lang.ClassCastException in the FireBug console, though the alert fires just fine. Suggestions?

like image 302
Carl Avatar asked Mar 08 '11 15:03

Carl


1 Answers

private native void publish(EntryPoint p) /*-{
 $wnd.setText = function(from) {
  alert(from);
  [email protected]::helloMethod(Ljava/lang/String;)(from);
 }
}-*/;

Could you give this code a try?

like image 53
Yusuf K. Avatar answered Nov 03 '22 01:11

Yusuf K.