Class PermissionButtonFactory
- All Implemented Interfaces:
DynamicActionAttributes
,ActionFactory<ButtonAction>
If the ClientContext
has a current item that is
an AccessControlled
item permissions are checked against
that item:
AccessControlled.hasPermission(Permission)
. If no item
type has been specified with setItem(String)
the factory will
accept any kind of item, otherwise it will only generate button
actions if the item type matches.
If the ClientContext
doesn't have a current item,
the factory checks the role-based permissions with
SessionControl.hasPermission(Permission, Item)
.
Permission levels can be set for when the button should be:
- visible and enabled
- visible but disabled
- hidden
AbstractJspActionFactory.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
The default settings will accept all items that the user has read access to and make the button visible and enabled.
If the extension point supports scripts and stylesheets, use the
AbstractJspFactory.setScript(String)
and AbstractJspFactory.setStylesheet(String)
methods.
Each call to these methods will add the argument to a set. Use
the AbstractJspFactory.getScripts()
and AbstractJspFactory.getStylesheets()
methods to gain
access to the sets, for example, to remove added items.
- Version:
- 2.7
- Author:
- nicklas
- Last modified
- $Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetActions
(InvokationContext<? super ButtonAction> context) This method may be called one or several times for each request.private boolean
hasPermission
(ClientContext cc, Item accepted, Permission permission) void
Set the class to use in all cases.void
setDisabledClazz
(String clazz) Set the class to use when the button is disabled.void
setDisabledIcon
(String icon) Set the icon to use when the button is disabled.void
setDisabledStyle
(String style) Set the style to use when the button is disabled.void
setDisabledTitle
(String title) Set the title of the button when it is disabled.void
setDisabledTooltip
(String tooltip) Set the tooltip of the button when it is disabled.void
setEnabledClazz
(String clazz) Set the class to use when the button is enabled.void
setEnabledIcon
(String icon) Set the icon to use when the button is enabled.void
setEnabledPermission
(String permission) Set the minimum permission that is required to make the button enabled.void
setEnabledStyle
(String style) Set the style to use when the button is enabled.void
setEnabledTitle
(String title) Set the title of the button when it is enabled.void
setEnabledTooltip
(String tooltip) Set the tooltip of the button when it is enabled.void
Set the icon to use in all cases.void
Set the ID of the button.void
Set the item type to check the permission for.void
setOnClick
(String onClick) void
Set the style to use in all cases.void
Set the title of the button in all cases.void
setTooltip
(String tooltip) Set the tooltip of the button in all cases.void
setVisiblePermission
(String permission) Set the minimum permission that is required to make the button visible.Methods inherited from class net.sf.basedb.clients.web.extensions.AbstractJspActionFactory
prepareContext
Methods inherited from class net.sf.basedb.clients.web.extensions.AbstractJspFactory
getDynamicActionAttributes, getParameter, getScripts, getStylesheets, prepareContext, setParameter, setScript, setStylesheet
-
Field Details
-
id
-
onClick
-
visiblePermission
-
enabledPermission
-
itemToCheck
-
enabledClazz
-
disabledClazz
-
enabledIcon
-
disabledIcon
-
enabledStyle
-
disabledStyle
-
enabledTitle
-
disabledTitle
-
enabledTooltip
-
disabledTooltip
-
-
Constructor Details
-
PermissionButtonFactory
public PermissionButtonFactory()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.
-
setEnabledPermission
Set the minimum permission that is required to make the button enabled.- Parameters:
permission
- One ofPermission
constants
-
setVisiblePermission
Set the minimum permission that is required to make the button visible.- Parameters:
permission
- One ofPermission
constants
-
setItem
Set the item type to check the permission for.- Parameters:
item
- One ofItem
constants or null to accept all items
-
setEnabledClazz
Set the class to use when the button is enabled. -
setDisabledClazz
Set the class to use when the button is disabled. -
setClazz
Set the class to use in all cases. -
setEnabledIcon
Set the icon to use when the button is enabled. -
setDisabledIcon
Set the icon to use when the button is disabled. -
setIcon
Set the icon to use in all cases. -
setId
Set the ID of the button. -
setOnClick
-
setEnabledStyle
Set the style to use when the button is enabled. -
setDisabledStyle
Set the style to use when the button is disabled. -
setStyle
Set the style to use in all cases. -
setEnabledTitle
Set the title of the button when it is enabled. -
setDisabledTitle
Set the title of the button when it is disabled. -
setTitle
Set the title of the button in all cases. -
setEnabledTooltip
Set the tooltip of the button when it is enabled. -
setDisabledTooltip
Set the tooltip of the button when it is disabled. -
setTooltip
Set the tooltip of the button in all cases. -
hasPermission
-