Ripla

Rich Platform project for Java web applications.

This project is maintained by aktion-hip

Context Menu IMenuSet

A view represents a certain position a user has reached in the use case. The context menu offers a restricted set of actions (i.e. directions the user can move on) at the actual position.

Therefore, a view's context menu is a context menu set (IMenuSet) that consists of one or more context menu items (IContextMenuItem). (An empty menu set is an option too.) On the other side, the same context menu item can reside in different context menu sets.

public interface IMenuSet {
    String getSetID();
    IContextMenuItem[] getContextMenuItems();
}

Each view's context menu is controlled by it's controller. To achieve this, each context menu set has to be uniquely identified (within the use case). With such an identification, the controller loads the suitable context menu set simply by calling its identification. These requirements define completely the interface of org.ripla.web.interfaces.IMenuSet. IMenuSet.getSetID() returns the context menu set's identification. IMenuSet.getContextMenuItems() returns a set of context menu item instances.

public interface IContextMenuItem {
    Class<? extends IPluggable> getControllerClass();
    String getTitleMsg();
    String getMenuPermission();
    boolean checkConditions(User inUser, Authorization inAuthorization, ParameterObject inParameters);
}

The context menu item has to define an action that has to be executed if the user clicks the context menu item. This is done by IContextMenuItem.getControllerClass().

IContextMenuItem.getTitleMsg() returns the label displayed by the context menu item.

IContextMenuItem.getMenuPermission() controlles whether the context menu item is displayed or not. If a user doesn't have the permission to display a view, the corresponding menu item has to be hidden to prevent the activation of the view's controller. Returning the menu permission is the standard way to control the display of a context menu item. With IContextMenuItem.checkConditions(), you can implement an alternative and more elaborate way to controll the menu item's display. This control can be based on the actual user (org.osgi.service.useradmin.User), the authorization context (org.osgi.service.useradmin.Authorization) and arbitrary additional information passed by a ParameterObject.

org.ripla.web.menu.ContextMenuItem provides a default implementation of IContextMenuItem. Bundles providing context menu items can create instances of this class. See The Context Menu for an example how to create a context menu set.