Ripla

Rich Platform project for Java web applications.

This project is maintained by aktion-hip

The Use Case's Main Menu

The following snippet shows how to create a menu for the application's main menu bar:

private IMenuItem createMenu() {
    final RiplaMenuComposite outMenu = new RiplaMenuComposite("Widgets", 10);
    outMenu.setControllerName(UseCaseHelper.createFullyQualifiedControllerName(InputWidgetsController.class));
    outMenu.setPermission(Constants.PERMISSION_INPUT_WIDGETS);
    RiplaMenuComposite lSubMenu = new RiplaMenuComposite("Button Widgets", 10);
    lSubMenu.setControllerName(UseCaseHelper.createFullyQualifiedControllerName(ButtonWidgetsController.class));
    outMenu.add(lSubMenu);
    lSubMenu = new RiplaMenuComposite("Selection Widgets", 20);
    lSubMenu.setControllerName(UseCaseHelper.createFullyQualifiedControllerName(SelectionWidgetsController.class));
    outMenu.add(lSubMenu);
    return outMenu;
}

The menu created (implementing the interface org.ripla.web.interfaces.IMenuItem) is a composite, i.e. a tree structure with arbitrary nesting levels. In the example above, the menu has a root node displaying the label "Widgets" in the application's main menu. The menu has a submenu containing two elements (with the labels "Button Widgets" and "Selection Widgets") which is displayed when the user hovers over the menu's root node.

Each node in the menu has to know which controller has to be activated when the user clicks the menu item. The mapping is done by the method org.ripla.web.menu.RiplaMenuItem.setControllerName(inControllerName). In addition, the programmer can set a permission. Thus, the application will hide menu entries if the user doesn't have sufficient permissions.