Your snippet to create a New Person instance in jsni will not work. Whilst the compiler will not report a compile time error,your code will fail whenver some java code attempts to do anything with that instance.
There are many wrong assumptions wwirh your advice... @ Properties and method names get mangled - you must jsni styled references to these rather than literals. @ The prototype is not set so any attempt to call real Person methods will also fail. Anything relati g to the type of the instance will also fail because the gwt emulation of java in is won't know what type your Person instance is. @ All you hav achieved is to create a fake but broken javascript object that is telling the compiler it's a Person but it's not... Hth On Mar 2, 8:01 pm, sutarsa giri <[email protected]> wrote: > sory, i make a mistake when pressing keyboard, so message sent before i > finish typing > > sample is like this > class Person extends JavaScriptObject{ > protected Person(){} > public native String getUserName ()/*-{return this.username.}-*/; > public native void setUserName(String name)/*-{this.username=name;}-*/; > > } > > and on jsni method : > private native Person test()/*-{ > var a={username:"some username"} > return a; > > }-*/; > > i think this trick will work > > On Mon, Mar 2, 2009 at 4:58 PM, sutarsa giri <[email protected]> wrote: > > you may could set the jsni method return instance of subclass of > > com.google.gwt.core.client.JavaScriptObject > > > for example : > > class Person extends JavaScriptObject{ > > > } > > > On Mon, Mar 2, 2009 at 4:34 PM, jagadesh <[email protected]>wrote: > > >> Hi i read the article. > >> i was able to get the primitive values liks String , int e.t.c. i want > >> an javascript object to be transmitted to java Code[Gwt ] . > > >> Thank u, > >> jagadesh. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
