>
> You'll see in the collections examples the
> constructors are still protected, i.e., they still need to be created
> by the underlying javascript (which is sketchy).
>

You could also write it like this

  // Return the whole JSON array, as is

  private final native JsArray<Customer> getCustomers() /*-{

    return new Array();
  }-*/;


That way, the json structure doesn't have to be in your html.

Next, you could write an set method like this -

public final native void set(int i, E e) /*-{this[i] = e;}-*/;

So, now you can create and add elements to your JsArray entirely from Java
code.

--Sri



On 3 May 2010 13:00, Robert J. Carr <rjc...@gmail.com> wrote:

> Ah ... spoke too soon.  You'll see in the collections examples the
> constructors are still protected, i.e., they still need to be created
> by the underlying javascript (which is sketchy).
>
> Anyway, it seems if I encapsulate all of the creation and manipulation
> of the array it will be transparent, I'm just not sure why this isn't
> in the standard library.
>
> On Mon, May 3, 2010 at 12:25 AM, Robert J. Carr <rjc...@gmail.com> wrote:
> > Hi Sri-
> >
> > That's a great reference, thanks, but it is effectively what I'm
> > already doing (just encapsulating it better).
> >
> > I think my point is, in the example they gave:
> >
> > class JsArray<E extends JavaScriptObject> extends JavaScriptObject { ...
> }
> >
> > I feel this should be part of the standard library.
> >
> > Anyway, thanks for the link, it was helpful.
> >
> > On Mon, May 3, 2010 at 12:09 AM, Sripathi Krishnan
> > <sripathikrish...@gmail.com> wrote:
> >> Have you tried using Javascript Overlays? See this page -
> >>
> http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsOverlay.html
> >> It allows you to pass objects back and forth, including JsArray. It has
> an
> >> example of JsArray<Customer> that you could peruse.
> >>
> >> --Sri
> >>
> >>
> >> On 3 May 2010 12:09, rjcarr <rjc...@gmail.com> wrote:
> >>>
> >>> I've recently began using a javascript library that is based on
> >>> (requires) jquery so I'll be needing to write a lot more JSNI than I
> >>> have in the past.
> >>>
> >>> I've actually got jquery working with jsni without too much trouble,
> >>> but now I'm having problems with data types.
> >>>
> >>> I struggled quite a bit getting a data structure passed into a JSNI
> >>> method, i.e., a list of String.  The only thing I could get to work
> >>> was to write a JSNI method to create an array and return it as a
> >>> JavaScriptObject (e.g, return []), then write another JSNI method to
> >>> put something in the array (e.g, jso.push(string)), and then finally
> >>> pass this built-up array into the expected JSNI method (with the
> >>> jquery I need).
> >>>
> >>> Is this the only way to do it?  It seems this could be easier if the
> >>> JsArrayString (and others similar) could be instantiated in Java, and
> >>> then usable in the JSNI, but that isn't possible.  Am I missing
> >>> something?
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Google Web Toolkit" group.
> >>> To post to this group, send email to
> google-web-tool...@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
> .
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/google-web-toolkit?hl=en.
> >>>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Google Web Toolkit" group.
> >> To post to this group, send email to
> google-web-tool...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
> .
> >> For more options, visit this group at
> >> http://groups.google.com/group/google-web-toolkit?hl=en.
> >>
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-tool...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to