Wednesday, March 23, 2016

Re: Complex Overlay Type

Thank you for this solution.
It works fine for me.

Regards, Michael

On Wednesday, March 23, 2016 at 4:16:26 AM UTC+1, Paul Stockley wrote:
So it looks like pages is actually a hashtable of pageid's to page objects. You can use a class similar to the following and define pages using it


public class JsMap<T> extends JavaScriptObject{

protected JsMap() {
}

public final native T get(String key) /*-{
return this[key] || null;
}-*/;

public final native void put(String key, T value) /*-{
this[key] = value;
}-*/;

public final native void remove(String key) /*-{
delete this[key];
}-*/;

public final native boolean hasKey(String key) /*-{
return this[key] !== undefined;
}-*/;

public final native JsArray<String> keys() /*-{
var o = [];

for(var prop in this) {
if (this.hasOwnProperty(prop))
o.push(prop);
}

return o;
}-*/;

public final native JsArray<T> values() /*-{
var o = [];
for (var prop in this) {
if (this.hasOwnProperty(prop)) {
o.push(this[prop]);
}
}
return o;
}-*/;

public static native <O> JsMap<O> createMap() /*-{
return {};
}-*/;
}

You can then iterate through the page(s) using the values method.



On Tuesday, March 22, 2016 at 8:08:54 PM UTC-4, Michael Esser wrote:
Hi there,

I'm trying to parse data from a wiki and want to use overlay types. For simple types I have no problem.
But in the following there is a property dynamicaly created by the server and I have no idea to get the data.
Any suggestions would be helpful.

Here the data:
The problem is the "4180" which is dfifferent for each call I didn't know it.
Nested types didn't solve the problem because I do not know the property "4180".

Thanks and best regards,
Michael
{      "batchcomplete": "",      "query": {          "pages": {              "4180": {                  "pageid": 4180,                  "ns": 0,                  "title": "Kalifornien",                  "revisions": [                      {                          "contentformat": "text/x-wiki",                          "contentmodel": "wikitext",                          "*": "{{quickbar\n| Lage={{Vorlage:USA-map|Map of USA CA.svg|Kalifornien|250px}}}}"                      }                  ]              }          }      }  }

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment