I have been attempting to do the following for a few days to no avail:
I have a GWT application that makes several RPC calls on startup to load initial data. For the most part, this data is relatively static, so I'd skip the RPC call if I could. But the data changes more often than the application does, so I'd rather not include it at compile time.
Instead, I take the data and store it in JSON in a static .js file. I include that in the loading HTML for the application:
html ... GWT loading stuff...>
script src="staticstuff.js">/script> //this is intentionally wrong so it will show on stackoverflow html with static stuff looking like:
var startupdata = [JSON.....];
Then, in the application itself, we do the following:
private native JsArrayString getStaticData()/*-{
return $wnd.startupdata;
}-*/;
This works perfectly fine when our data is an array, or string, or some other JS native object. What I cannot seem to do is the following:
private native OurMoreComplexObject getStaticData()/*-{
return $wnd.startupdata;
}-*/;
I could pull back the js objects and parse them into my object graph myself, but I'd prefer not to, especially since GWT already created a converter for me (since OurMoreComplexObject) is already returned in RPC calls.
Has anyone attempted something like this before? If so, how do I get it to work? Is there some other way to do this? (The main goal is that if the data is stored in a file, I can load it onto our CDN instead of forcing the call back to our servers at startup every time)