public class PermissionMenuItemFactory extends AbstractJspActionFactory<MenuItemAction>
The permissions are checked for a given item type
(setItem(String)
). Permission levels can be
set for when the menu item should be:
prepareContext(InvokationContext)
method. Most
properties can have different values for the enabled/disabled state.
For example:
setTitle(String)
sets the title for both states
setDisabledTitle(String)
sets the title for the disabled state
setEnabledTitle(String)
sets the title for the enabled state
Modifier and Type | Field and Description |
---|---|
private String |
disabledClazz |
private String |
disabledIcon |
private String |
disabledStyle |
private String |
disabledTitle |
private String |
disabledTooltip |
private String |
enabledClazz |
private String |
enabledIcon |
private Permission |
enabledPermission |
private String |
enabledStyle |
private String |
enabledTitle |
private String |
enabledTooltip |
private String |
id |
private Item |
itemToCheck |
private String |
menuId |
private String |
onClick |
private String |
submenuId |
private MenuItemAction.MenuType |
type |
private Permission |
visiblePermission |
Constructor and Description |
---|
PermissionMenuItemFactory()
Create a new factory instance.
|
Modifier and Type | Method and Description |
---|---|
MenuItemAction[] |
getActions(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 the
JspContext . |
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 |
setIcon(String icon)
Set the icon to use in all cases.
|
void |
setId(String id) |
void |
setItem(String item)
Set the item type to check the permission for.
|
void |
setMenuId(String menuId) |
void |
setOnClick(String onClick)
Deprecated.
|
void |
setStyle(String style)
Set the style to use in all cases.
|
void |
setSubmenuId(String submenuId) |
void |
setTitle(String title)
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 |
setType(MenuItemAction.MenuType type)
Set the type of the menu.
|
void |
setType(String type)
Set the type of menu.
|
void |
setVisiblePermission(String permission)
Set the minimum permission that is required to make the
menu item visible.
|
getDynamicActionAttributes, getParameter, getScripts, getStylesheets, prepareContext, setParameter, setScript, setStylesheet
private String id
private String enabledClazz
private String disabledClazz
private String onClick
private MenuItemAction.MenuType type
private String menuId
private String submenuId
private Permission visiblePermission
private Permission enabledPermission
private Item itemToCheck
private String enabledIcon
private String disabledIcon
private String enabledStyle
private String disabledStyle
private String enabledTitle
private String disabledTitle
private String enabledTooltip
private String disabledTooltip
public PermissionMenuItemFactory()
public MenuItemAction[] getActions(InvokationContext<? super MenuItemAction> context)
ActionFactory
context
- The current invokation contextpublic boolean prepareContext(InvokationContext<? super MenuItemAction> context)
AbstractJspActionFactory
JspContext
. A subclass that
overrides this method should call super.prepareContext()
if it hasn't decided to return FALSE already.prepareContext
in interface ActionFactory<MenuItemAction>
prepareContext
in class AbstractJspActionFactory<MenuItemAction>
context
- The current invokation contextpublic void setEnabledPermission(String permission)
permission
- One of Permission
constantspublic void setVisiblePermission(String permission)
permission
- One of Permission
constantspublic void setItem(String item)
item
- One of Item
constants@VariableSetter @PathSetter public void setEnabledIcon(String icon)
@VariableSetter @PathSetter public void setDisabledIcon(String icon)
@VariableSetter @PathSetter public void setIcon(String icon)
public void setMenuId(String menuId)
@VariableSetter @Deprecated public void setOnClick(String onClick)
public void setId(String id)
public void setDisabledClazz(String clazz)
public void setEnabledClazz(String clazz)
public void setEnabledStyle(String style)
public void setDisabledStyle(String style)
public void setStyle(String style)
public void setSubmenuId(String submenuId)
public void setEnabledTitle(String title)
public void setDisabledTitle(String title)
public void setTitle(String title)
public void setEnabledTooltip(String tooltip)
public void setDisabledTooltip(String tooltip)
public void setTooltip(String tooltip)
public void setType(MenuItemAction.MenuType type)
public void setType(String type)
private boolean hasPermission(SessionControl sc, Permission permission)