Documentation

Trace: Flatten menu

(vaadin)

Flatten menu

Usually, the corporation menu items will be shown in groups (e.g. MDM, Admin):

The menu bar contains menus with menu items, for each screen, e.g. the menu Admin contains Statistic and Company screen.

But sometimes you want flat menus, e.g.

This can be done with your own Menu implementation, e.g.

public class FlatMenuBarCorporation extends WebMenuCorporation 
{
    public FlatMenuBarCorporation(IApplication pApplication) 
    {
        super(pApplication);
    }
 
    @Override
    protected IMenuItem addMenuItem(String pId,
                                    String pGroupId,
                                    String pAction, 
                                    String pActionCommand,
                                    String pGroup,
                                    String pGroupImage, 
                                    String pShortcut,
                                    String pText, 
                                    String pImage,
                                    boolean pUseSeparator,
                                    boolean pToggle)
    {
        if ("Admin".equals(pGroup))
        {
            UIMenuBar bar = getMenuBar();
 
            UIMenuItem miItem = createMenuItem(pAction, pActionCommand, pText, UIImage.getImage(pImage));
 
            bar.add(miItem);
 
            return miItem;
        }
        else
        {
            return super.addMenuItem(pId, pGroupId, pAction, pActionCommand, pGroup, 
                                     pGroupImage, pShortcut, pText, pImage, pUseSeparator, pToggle);
        }
    }
}

To use the custom menu, simply change the corporation menu class name in your deployment descriptor, e.g.

<init-param>
  <param-name>Application.Menu.corporation.classname</param-name>
  <param-value>com.sibvisions.apps.vaadin.FlatMenuBarCorporation</param-value>
</init-param>

In newer versions, it's possible to set:

<init-param>
  <param-name>Application.Menu.corporation.groups.flat</param-name>
  <!-- comma separated list of group names -->
  <param-value>Admin</param-value>
</init-param>

instead of your custom menu implementation.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information