2 Replies Latest reply on Jun 19, 2010 6:42 AM by vestnik

    How to not render empty rich:panelMenuGroup

    vestnik

      Hello

       

      I'm using  rich:panelMenu for main menu in my application. There are several rich:panelMenuGroup each of them contains several items. Depending on the logged in user permissions some of items may be not rendered (using rendered="#{s:hasPermission('item_target','read')}" attribute). Some user may have several completely empty groups which is not good. I want to render group at all if it's empty.

       

      There is a trivial way like rendered="#{s:hasPermission('item1_target','read') or s:hasPermission('item2_target','read') or ...}" but in this case there will be code duplication which may cause unpleasant issues if menu item is moved from one group to another.

       

      I've looked through the rich:panelMenuGroup tag documentation and didn't fount the way to hide empty group. Is there any way to not render whole rich:panelMenuGroup if none of it's child element is rendered?

        • 1. Re: How to not render empty rich:panelMenuGroup
          akaine

          Option #1: declare boolean variables in the backing bean, calculate their value on Java level and set them as rendered values (could use a List<Boolean> for this to avoid multiple variables, in EL you get each element from the list like this: myBooleanList[index]).

          Option #2: construct the whole menu programmatically (recommended) and bind the menu variable to the element (here's an example of something similar)

          1 of 1 people found this helpful
          • 2. Re: How to not render empty rich:panelMenuGroup
            vestnik

            First option looks not much better then calling permission check from EL in the template. I'll use the second option if there is no way to do what I want from template having "static" menu.