Hi,
Check out the JSNI documentation here:
http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=DevGuideMarshaling,
which talks about the JavaScriptObject that you want to use.
Basically you can hold on to an javascript object that is opaque to
the java code. You can either pass it to future calls, or access the
member directly from your class:
public class GWTCar
{
private JavaScriptObject jsCar;
public GWTCar()
{
jsCar = allocateJsObject();
driveCar(jsCar); // Pass the car to this version
altDriveCar(); // This version retrieves it from the class
}
public native JavaScriptObject allocateJsObject()
/*-{
Car car = new Car();
return car;
}-*/
public native void driveCar(JavaScriptObject car)
/*-{
car.drive("NY", "LA");
}-*/
public native void altDriveCar()
/*-{
var car = [EMAIL PROTECTED]::jsCar;
car.drive("NY", "LA");
}-*/
}
Your best bet is to actually wrap the javascript functionality in a
separate class, which can then be created and accessed fully in Java,
as shown above, so the javascript is fully encapsulated away.
jk
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---