|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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
public class PermissionMenuItemFactory
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:
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
Field Summary | |
---|---|
private String |
disabledIcon
|
private String |
disabledStyle
|
private String |
disabledTitle
|
private String |
disabledTooltip
|
private String |
enabledIcon
|
private Permission |
enabledPermission
|
private String |
enabledStyle
|
private String |
enabledTitle
|
private String |
enabledTooltip
|
private Item |
itemToCheck
|
private String |
menuId
|
private String |
onClick
|
private String |
submenuId
|
private MenuItemAction.MenuType |
type
|
private Permission |
visiblePermission
|
Constructor Summary | |
---|---|
PermissionMenuItemFactory()
Create a new factory instance. |
Method Summary | |
---|---|
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 |
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 |
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 |
setItem(String item)
Set the item type to check the permission for. |
void |
setMenuId(String menuId)
|
void |
setOnClick(String onClick)
Set the javascript action to call when the menu is clicked. |
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. |
Methods inherited from class net.sf.basedb.clients.web.extensions.AbstractJspFactory |
---|
getScripts, getStylesheets, prepareContext, setScript, setStylesheet |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
public PermissionMenuItemFactory()
Method Detail |
---|
public MenuItemAction[] getActions(InvokationContext<? super MenuItemAction> context)
ActionFactory
context
- The current invokation context
public 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 context
public 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 public void setOnClick(String onClick)
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)
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |