I’m looking for an example or a description how to apply the NodeTreeContentProvider on the result set of a web service.
I’m able to feed a search result tree with static data like in the wm_corecontrolstest but I didn’t find any example how to use a ContentProvider in a web service scenario. I need a hint where to place the conversion of the flat web service result to a hierarchical data structure.
Assuming the web service returns an XML string, something like this should work:
private NodeTreeContentProvider menuTreeProvider = null;
...
public NodeTreeContentProvider getMyTreeProvider() {
String myXml = getGetWebService().getResult().getXmlResult();
myTreeProvider = loadXML(myXml);
return myTreeProvider;
}
...
public NodeTreeContentProvider loadXML(String xmlResult) {
Document doc = XMLUtil.loadDocumentFromXML(xmlResult);
//each node needs a unique id -- in this case each tag has an id attribute
XMLDOMNode2 docNode = new XMLDOMNode2(doc.getDocumentElement(), "@id");
myTreeProvider = new NodeTreeContentProvider(docNode);
return myTreeProvider;
}
...
Since my web service was used for a Search Table before it returns a flat result and not XML. But building a tree data structure for the NodeTreeContentProvider was the easier step.
My main problem was where to get access to the web service result set and where to integrate my implementation of the tree. The two Servlets SearchBar and SearchResult work close together. The documentation is limited to the description of APIs. No description available of the interaction. All examples use the Search Table, none of them uses the Search Tree. The documentation of the ContentProvider is rather poor, too, although requested in years old threads.
Currenty, I’ve integrated my tree building implementation in the method ‘beforeRenderReponse’. I works but I’m not happy with the solution because this method seems to be called at least twice after performing a search.