JSF + Dynatree 制作树表示
我想画一棵在 JSF 中生成的树。
我认为我应该使用 DynaTree 并避免使用组件库,尽管看到解决方案的复杂性我开始重新考虑。
我想我可以使用 Javascript
的隐藏输入传递树的字符串表示形式,然后在那里构建树。
有没有我没有想到的更好的解决方案?
使用JSF2.0
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终所做的是生成一个表示树的 JSON 字符串(以 dynatree 格式),然后在另一端(浏览器)简单地使用 JSON.Parse() 来生成一棵树。
相关代码是:
Java 树节点:
生成树字符串:
该字符串通过 JSF 传递到
,然后是
JavaScript
解析: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 theJavaScript
parsing:我同意你的观点,dynatree 是一个强大且经过验证的组件。相反,一些 JSF 原生树组件的功能较少。
我已经启动了 dynatree 的适配器。你可以在这里找到源代码 https://github.com/nithril/dynatree-for-jsf
欢迎评论!
I agree with you than dynatree is a robust and a proven component. On the contrary of some JSF native tree components that have less features.
I have start an adapter for dynatree. You could find the source here https://github.com/nithril/dynatree-for-jsf
Comments are welcome!