I’d like to draw a tree that is generated in JSF.
I thought I’d use DynaTree and avoid using component libraries, although i’m starting to have second thoughts seeing the complexity of the solution.
I thought I could pass a String representation of the tree using a hidden input to Javascript and then build the tree there.
Is there a better solution that I had not thought of?
Using JSF2.0
What I eventually did is to generate a JSON string that represents the tree (in dynatree format) and then simply use JSON.Parse() on the other side (browser) to make a tree out of it.
The relevant code is:
The Java tree node:
Generate the Tree String:
The String is passed through JSF into an
<h:inputText id="tree" style="display:none" />and then theJavaScriptparsing: