Ok those links and examples provided helped a lot, I think I have most
of it now.

One problem though, when allocating my javascript object, execution
just kind of dies with no error when trying to allocate an internal
DOMParser instance, like:

  // car.js
  Car = function() {
      var parser = new DOMParser();
  }


I'm not sure why this is, I'm just testing by placing alerts around
the code (sadly). The execution stops on that line and returns back to
my original allocation function, and the returned JavaScriptObject
instance is null:

  private native JavaScriptObject _allocateCar() /*-{
      return new $wnd.Car();  // will return null.
  }-*/;

Whether this is related or not, I don't know, but I have to place
"$wnd" before the type in order for GWT to take it. Well I'm pretty
much stuck on this, if anyone has any ideas that'd be great. This is a
3rd party library I'm trying to use, it'd be a lot easier if it were
in GWT already,

Thanks






On Nov 15, 2:08 pm, Shawn Pearce <[EMAIL PROTECTED]> wrote:
> Look at 
> JavaScriptObject:http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=goog...
>
> In particular you might write something like this:
>
> public class Car extends JavaScriptObject {
>   public static final native Car newCar() /*-{ return new Car(); }-*/;
>
>   protected Car() {
>   }
>
>   public final native void drive(String from, String to)/*-{
> this.drive(from, to); }-*/
>
> }
> On Sat, Nov 15, 2008 at 11:00, markww <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Can we use objects created in native javascript code in our GWT apps?
> > There's a library I want to use which creates an object and uses it
> > like:
>
> >    Car = new Car();
> >    car.onDrive = function(ntype, from, to) {
> >        if (! ntype) {
> >            whatever();
> >        }
> >    }
>
> > I wouldn't have a representation of this object in my GWT code, I
> > guess it would just live in JNDI blocks. But I'm not sure how we go
> > about doing something like that. In my mind it would look something
> > like:
>
> > public class MyAppGWT implements EntryPoint
> > {
> >    public void onModuleLoad()
> >    {
> >         // Allocate native js which I want to be persistent
> > somehow...
> >         allocateJsObject();
> >    }
>
> >    public static native void allocateJsObject()
> >  /*-{
> >        <script src="http://lpath_to_lib_src/GreatLibrary.js";></
> > script>
> >        Car car = new Car();
> >        car.onDrive = function(from, to) {
> >            return "ok driving?";
> >    }-*/;
>
> >    public static native void driveWrapper()
> >  /*{
> >       // Recover the global car instance somehow and use it?
> >       car.drive("NY", "LA");
> >    }*/;
>
> > Yeah so how will "Car" persist in the application - is it now alive
> > for the duration of my app, or will it die after allocateJsObject()
> > exits? The object itself only really takes in  and then produces
> > text,so I'm guessing it is possible to hook up in some way.
>
> > Thanks
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to