I used to get my JSON data for my Web App using Google/alt-json-in-script,
using the native method specified in the original documentation to do so.
This worked well... until I wanted to use the "new" method,
JsonpRequestBuilder and the Visualization API instead, for an application
where I was making up to twelve different requests from the same spreadsheet
- querying the spreadsheet to limit the amount of data returned.
I thought: what better than to just grab the data only twice in one gigantic
chunk, and then manipulate it in Java GWT where I'm supposed to? (Plus, it
would make my code easier to read, debug, and reuse.)
The problem is that the Google spreadsheet I'm using is quite large - 27
columns across, and around 1,000 rows.
After creating a new JsonpRequestBuilder, using a callback hack, and
grabbing the data... it craps out after processing 26 rows successfully.
*java.lang.IllegalArgumentException: Something other than a Java object was
returned from JSNI method
'@collegesportssource.client.SchedSpreadsheetResponseJso$JsonSchedEntry::getTixlink()':
JS value of type int, expected java.lang.Object*
In the spreadsheet, getTixLink is a valid value, not an integer like it says
here. I made sure of this by adding a row in the spreadsheet before the
error. Sure enough, after 26 rows, same place, one row up, it gets the same
error.
Looking at the URL from the Visualization API, it brings back all the data
successfully. So it's not a problem with the API, it's a problem within
GWT.
So, my questions are:
* Is there a limit to the amount of JSON data transported by a singular
JavaScriptObject via the JsonpRequestBuilder?
* Is there a way I can increase the size of this limit? (Is it worth it?)
* If I can't, what sort of workaround can I use? If I have to I could go
back to my old, hard-to-debug-but-works version of native Javascript calls,
but I would prefer not to.
Background:
SchedSpreadsheetResponseJso is an overlay type that contains my Spreadsheet
record.
private void loadSchedule() {
requestJsonSchedData(new
AsyncCallback<SchedSpreadsheetResponseJso>() {
@Override
public void onFailure(Throwable caught) {
Window.alert("Failure:" + caught.getMessage());
}
@Override
public void onSuccess(SchedSpreadsheetResponseJso result) {
for( int count = 0; count < result.getColumns().length();
count++) {
JsonSchedEntry jsonSchedEntry =
result.getRows().get(count);
addToSchedArray(field1, field2, field3.. field27);
}
}
});
}
private static void
requestJsonSchedData(AsyncCallback<SchedSpreadsheetResponseJso> callback) {
JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
jsonp.setTimeout(1000);
jsonp.requestObject(TEAM_SCHED, callback);
registerGoogleVisualizationAPICallbackMethod();
}
private static native void
registerGoogleVisualizationAPICallbackMethod() /*-{
$wnd.google = new Object();
var google = $wnd.google;
google.visualization = new Object();
var query = google.visualization.Query = new Object();
var counter = $wnd['__gwt_jsonp__']['__gwt_jsonp_counter__']-1;
query.setResponse = function(param) {
$wnd['__gwt_jsonp__']['I'+counter].onSuccess(param);
};
}-*/;
--
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.