[英]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. 我一直在使用SmartGWT的数据源从Web服务获取数据并将其放入ListGrid。 This has worked well because there were no sub elements.
因为没有子元素,所以效果很好。 However, now I have an XML structure as follows:
但是,现在我有一个XML结构,如下所示:
<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 allow me to retrieve the data I need either.
没有什么像setSubRecordXPath一样,我也看不到如何使用值XPath允许我检索我需要的数据。 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).
SmartGWT Showcase示例都是相对简单的结构(我看到了)。
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. 如果很重要,我可以访问代表这些各个字段的JAXB注释类,但是我不知道如何在SmartGWT框架中使用它们。
You can override the execute method of DSCallback when calling the data source's fetchData method. 调用数据源的fetchData方法时,可以覆盖DSCallback的execute方法。 Basically I use getAttributeAsRecordArray on those things that are supposed to be logical records.
基本上,我在应该是逻辑记录的那些东西上使用getAttributeAsRecordArray。 Still working on it but it's looking promising so far.
仍在努力,但到目前为止看起来很有希望。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.