简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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