Class PermissionMenuItemFactory
java.lang.Object
net.sf.basedb.clients.web.extensions.AbstractJspFactory
net.sf.basedb.clients.web.extensions.AbstractJspActionFactory<MenuItemAction>
net.sf.basedb.clients.web.extensions.menu.PermissionMenuItemFactory
- All Implemented Interfaces:
DynamicActionAttributes
,ActionFactory<MenuItemAction>
A menu item factory that can hide or disable menu items based
on the logged in user's permissions. It is possible to set
different text, tooltip, icon, etc. for a disabled menu.
The permissions are checked for a given item type
(setItem(String)
). Permission levels can be
set for when the menu item should be:
- visible and enabled
- visible but disabled
- hidden
prepareContext(InvokationContext)
method. Most
properties can have different values for the enabled/disabled state.
For example:
setTitle(String)
sets the title for both statessetDisabledTitle(String)
sets the title for the disabled statesetEnabledTitle(String)
sets the title for the enabled state
- Version:
- 2.7
- Author:
- nicklas
- Last modified
- $Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate String
private String
private String
private String
private String
private String
private String
private Permission
private String
private String
private String
private String
private Item
private String
private String
private MenuItemAction.MenuType
private Permission
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetActions
(InvokationContext<? super MenuItemAction> context) This method may be called one or several times for each request.private boolean
hasPermission
(SessionControl sc, Permission permission) boolean
prepareContext
(InvokationContext<? super MenuItemAction> context) If scripts and stylesheets has been added to the factory, propagates those to theJspContext
.void
setDisabledClazz
(String clazz) Set the class to use when the menu is disabled.void
setDisabledIcon
(String icon) Set the icon to use when the menu is disabled.void
setDisabledStyle
(String style) Set the style to use when the menu is disabled.void
setDisabledTitle
(String title) Set the title of the menu item when it is disabled.void
setDisabledTooltip
(String tooltip) Set the tooltip of the menu item when it is disabled.void
setEnabledClazz
(String clazz) Set the class to use when the menu is enabled.void
setEnabledIcon
(String icon) Set the icon to use when the menu is enabled.void
setEnabledPermission
(String permission) Set the minimum permission that is required to make the menu item enabled.void
setEnabledStyle
(String style) Set the style to use when the menu is enabled.void
setEnabledTitle
(String title) Set the title of the menu item when it is enabled.void
setEnabledTooltip
(String tooltip) Set the tooltip of the menu item when it is enabled.void
Set the icon to use in all cases.void
void
Set the item type to check the permission for.void
void
Set the style to use in all cases.void
setSubmenuId
(String submenuId) void
Set the title of the menu item in all cases.void
setTooltip
(String tooltip) Set the tooltip of the menu item in all cases.void
Set the type of menu.void
Set the type of the menu.void
setVisiblePermission
(String permission) Set the minimum permission that is required to make the menu item visible.Methods inherited from class net.sf.basedb.clients.web.extensions.AbstractJspFactory
getDynamicActionAttributes, getParameter, getScripts, getStylesheets, prepareContext, setParameter, setScript, setStylesheet
-
Field Details
-
id
-
enabledClazz
-
disabledClazz
-
type
-
visiblePermission
-
enabledPermission
-
itemToCheck
-
enabledIcon
-
disabledIcon
-
enabledStyle
-
disabledStyle
-
enabledTitle
-
disabledTitle
-
enabledTooltip
-
disabledTooltip
-
-
Constructor Details
-
PermissionMenuItemFactory
public PermissionMenuItemFactory()Create a new factory instance.
-
-
Method Details
-
getActions
Description copied from interface:ActionFactory
This method may be called one or several times for each request. This is decided by the extension point. If, for example, the extension point is a pure single-item extension point then this method is probably only called once. If the extension point is a per-item extension point in a list context, then this method may be called once for every item in the list. The context parameter contains all information about the context of the extension point, including the current item, if any.- Parameters:
context
- The current invokation context- Returns:
- An array of actions that should be added to the extension point. Returns null or an empty array if there are no actions in the current context.
-
prepareContext
Description copied from class:AbstractJspActionFactory
If scripts and stylesheets has been added to the factory, propagates those to theJspContext
. A subclass that overrides this method should callsuper.prepareContext()
if it hasn't decided to return FALSE already.- Specified by:
prepareContext
in interfaceActionFactory<MenuItemAction>
- Overrides:
prepareContext
in classAbstractJspActionFactory<MenuItemAction>
- Parameters:
context
- The current invokation context- Returns:
- Always TRUE
-
setEnabledPermission
Set the minimum permission that is required to make the menu item enabled.- Parameters:
permission
- One ofPermission
constants
-
setVisiblePermission
Set the minimum permission that is required to make the menu item visible.- Parameters:
permission
- One ofPermission
constants
-
setItem
Set the item type to check the permission for.- Parameters:
item
- One ofItem
constants
-
setEnabledIcon
Set the icon to use when the menu is enabled. -
setDisabledIcon
Set the icon to use when the menu is disabled. -
setIcon
Set the icon to use in all cases. -
setMenuId
-
setId
-
setDisabledClazz
Set the class to use when the menu is disabled. -
setEnabledClazz
Set the class to use when the menu is enabled.- Since:
- 3.3
-
setEnabledStyle
Set the style to use when the menu is enabled. -
setDisabledStyle
Set the style to use when the menu is disabled. -
setStyle
Set the style to use in all cases. -
setEnabledTitle
Set the title of the menu item when it is enabled. -
setDisabledTitle
Set the title of the menu item when it is disabled. -
setTitle
Set the title of the menu item in all cases. -
setEnabledTooltip
Set the tooltip of the menu item when it is enabled. -
setDisabledTooltip
Set the tooltip of the menu item when it is disabled. -
setTooltip
Set the tooltip of the menu item in all cases. -
setType
Set the type of menu. -
hasPermission
-