简体   繁体   English

从rich:tree生成rich:menu层次结构

[英]Generate rich:menu hierarchical structure from rich:tree

What i want to do: I want to make the menu of my application customizable, giving the user the possibility of changing the order of the menus. 我想做的事情:我想使应用程序的菜单可定制,从而使用户可以更改菜单的顺序。 For this i have build a tree (rich:tree) representing the menus in my application. 为此,我建立了一个树(rich:tree),代表我的应用程序中的菜单。 By drag-n-drop the user can change the order of the menus. 通过拖放,用户可以更改菜单的顺序。 The menus are kept in a xhtml file (a hierarchical structure of rich:menuGroup and rich:menuItems) 菜单保存在xhtml文件中(rich:menuGroup和rich:menuItems的层次结构)

What my problem is: When the user finishes drag-n-drop, on save i should generate xhtml code corresponding to my tree. 我的问题是:当用户完成拖放操作后,在保存时我应生成与我的树相对应的xhtml代码。 More concrete: For each parent node in the tree generate a rich:menuGroup and for each leaf node generate a rich:menuItem. 更具体的说:为树中的每个父节点生成一个rich:menuGroup,为每个叶节点生成一个rich:menuItem。 By traversing the tree i should build a hierarchical structure with menu groups containing other menu groups and/or menu items. 通过遍历树,我应该使用包含其他菜单组和/或菜单项的菜单组来构建层次结构。

Is there any tool or easy way for doing this? 有什么工具或简单的方法可以做到这一点吗? It would be a real pain to traverse the tree and manually concatenate hard-coded strings or something like that. 遍历树并手动连接硬编码的字符串或类似的东西将是一个真正的痛苦。

Thanks 谢谢

You can use ui:repeat tag, and create menuGroups from an array in the backing bean that you created according to the tree structure. 您可以使用ui:repeat标记,并根据根据树结构在后备bean中的数组中创建menuGroups。 In the array, properties of each menuGroup should be provided. 在数组中,应提供每个menuGroup的属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM