SmartGWT data retrieval with complex XML/JSON
I've been using SmartGWT's data source to fetch data from a web service and put it into a ListGrid. This has worked well because there were no sub elements. However, now I have an XML structure as follows:
<persons>
<person>
<field1>blah</field1>
<field2>blah2</field2>
<tests>
<test>
<testName>name</testName>
<testValue>value</testValue>
</test>
</tests>
<answers>
<answer>
<answerField>blah</answerField>
<answerField2>blah2</answerField2>
</answer>
</answers>
</person>
How would I use a datasource to put the person fields in one list grid, the test sub elements in another, and the answer sub elements in yet another? There's nothing like setSubRecordXPath and I don't see how using the value XPath would allo开发者_C百科w me to retrieve the data I need either. I also don't see how I could use multiple data sources.
Could someone show me how to do this or point me to a resource? The SmartGWT Showcase examples were all of a relatively simple structure (that I saw).
If it matters, I do have access to JAXB annotated classes that represent these various fields but I wouldn't know how to use them within the SmartGWT framework.
You can override the execute method of DSCallback when calling the data source's fetchData method. Basically I use getAttributeAsRecordArray on those things that are supposed to be logical records. Still working on it but it's looking promising so far.
精彩评论