It is doable, but it is not quite as straightforward. Tree branches are modeled
as instances of List, but they also have properties such as "label" and "icon".
An XML element is easily modeled as a list with properties, but JSON doesn't
have a similar construct: a JSON list can't have properties, and a JSON map
can't have indexed children. That's why the data is copied in the JSON viewer
example.
It might be possible to wrap a JSON structure such as the following in a custom
tree node class:
root: {
label: "Foo",
children: [
{label: "Bar 1", children: [ ... ] },
{label: "Bar 1", children: [ ... ] }, ...
]
}
public class TreeNode implements List<TreeNode> {
public String getLabel() { ... }
// etc.
}
You could try prototyping that and see what kind of issues you might run into.
G
On Mar 26, 2011, at 7:19 AM, sjcarroll6 wrote:
> I've been skimming the tutorial and wanted to know if there was an equivalent
> JSON based TreeView similar to the JSON based Table View. In demo's I know
> there is the JSON-Viewer app which programmatically builds the tree but I
> was curious if you could also do it by supplying JSON similar to the XML
> example.
>
> Thanks
>
> --
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/JSON-Based-Tree-View-tp2735068p2735068.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.