On 18 mar, 23:49, Farrukh Najmi <[email protected]> wrote: > I have the following code that processes a JavaScriptObject that is expected > to be a JsArray: > > JavaScriptObject jso = ... > JsArray jsa = jso.cast(); > int cnt = jsa.length(); > > I am finding that if the JsArray has a single element then jsa.length() > results in following exception. > All is well if there are 2 or more elements: > > com.google.gwt.dev.shell.HostedModeException: Expected primitive type int; > actual value was undefined [...] > Is this a known issue or am I doing something wrong?
I'm extensively using JsArrayXXX/JsArray<> without any problem, including with 1-item arrays. arr.length() translates into a bare arr.length in JS, so if arr.length is "undefined", it means that arr is not a JS array (or is not a JS object having a length property). What does a Window.alert(arr.toString()) shows? How about Window.alert (new JSONArray(arr).toString()) and Window.alert(JSONObject (arr).toString())? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
