Hi
I'm having quite some trouble getting a task done and unfortunately i couldn't find any solution by searching the forum or the web.
So here's my problem:
I'm using a listgrid to display my data and a datasource to retrieve them.
my listgrid displays the following fields:
type | published | name | directory
My XML i get as a response from the server looks the following:
the datasource fields look like this:
so here's the point where it gets complicated:
the values for the fields 'name' and 'published' are not contained in the feed.
to get them, i have to load the payload from the URL specified in in the 'src' attribute of the <content> tag.
what I've done so far is:
This results in the 'name' and 'directory' field of my listgrid beeing empty after the first fetch,
because the response of the asynchronous requests arrive after the GUI has been drawn.
The XML I get from the server is standardised and fixed. I do not have the option to change anything there;
Versions are GWT 2.6.1 and SmartGWT 4.1.
So does anyone have an idea on how to resolve this issue best?
Thanks in advance!
I'm having quite some trouble getting a task done and unfortunately i couldn't find any solution by searching the forum or the web.
So here's my problem:
I'm using a listgrid to display my data and a datasource to retrieve them.
my listgrid displays the following fields:
type | published | name | directory
My XML i get as a response from the server looks the following:
Code:
<feed xmlns="http://www.w3.org/2005/Atom"> <title type="text">Server log feed</title> <id>someId</id> <updated>timestamp</updated> <author> <name>author</name> <uri>uri</uri> </author> <link rel="self" type="application/atom+xml;type=feed" href="http://127.0.0.1/status.feed"/> <entry> <id>ID</id> <title type="text">SERVER_ID.log</title> <published>timestamp</published> <updated>timestamp</updated> <link rel="self" type="someType" href="someLink"/> <link rel="model" type="someType" title="title" href="someLink"/> <category term="FINISHSTATE_SUCCESS"/> <content type="someType" src="http://127.0.0.1/status/ID.payload"/> </entry> <entry> another entry... </entry> </feed>
Code:
DataSourceTextField type = new DataSourceTextField("type", "Type"); recentType.setValueXPath("./atom:link[@rel=\"model\"]/@title"); DataSourceDateTimeField published = new DataSourceDateTimeField("published", "Published"); recentDate.setValueXPath("./atom:published"); DataSourceTextField name = new DataSourceTextField("name", "Name"); DataSourceTextField directory = new DataSourceTextField("directory", "Directory");
so here's the point where it gets complicated:
the values for the fields 'name' and 'published' are not contained in the feed.
to get them, i have to load the payload from the URL specified in in the 'src' attribute of the <content> tag.
what I've done so far is:
Code:
final DataSource dataSource = new DataSource(UrlBuilder.getUrl("status.feed")) { @Override protected void transformResponse(DSResponse response, DSRequest request, Object data) { for (final Record record : response.getData()) { String contentString = record.getAttribute("content"); if (contentString != null && !contentString.isEmpty()) { JavaScriptObject jsObject = JSOHelper.getAttributeAsJavaScriptObject(record.getJsObj(), "content"); String url = JSOHelper.getAttribute(jsObject, "src"); new HttpConnection().getXml(url, new XmlValueHandler() { @Override public void onXmlValue(String path, String value) { Payload payload = new Payload(); payload.fromXml(value); record.setAttribute("name", payload.get("name")); record.setAttribute("directory", payload.get("directory")); } @Override public void onFailure(Response response) { } @Override public void onError(Throwable exception) { } }); } } } }; dataSource.setDataFormat(DSDataFormat.XML); dataSource.setXmlNamespaces(...); //set atom namespace dataSource.setRecordXPath("/atom:feed/atom:entry");
because the response of the asynchronous requests arrive after the GUI has been drawn.
The XML I get from the server is standardised and fixed. I do not have the option to change anything there;
Versions are GWT 2.6.1 and SmartGWT 4.1.
So does anyone have an idea on how to resolve this issue best?
Thanks in advance!
Comment