开发者

Generate rich:menu hierarchical structure from rich:tree

开发者 https://www.devze.com 2023-03-23 14:05 出处:网络
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

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. 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)

What my problem is: When the user finishes drag-n-drop, on save i should generate xhtml code corresponding to my tree. More concrete: For each parent node in the tree generate a rich:menuGroup and for each leaf node generate a rich:menuItem. By traversing the tree i should build a hierarchical structure with menu groups containing other menu开发者_StackOverflow中文版 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. In the array, properties of each menuGroup should be provided.

0

精彩评论

暂无评论...
验证码 换一张
取 消