|
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<ButtonAction> net.sf.basedb.clients.web.extensions.toolbar.PermissionButtonFactory
public class PermissionButtonFactory
A button factory that can hide or disable button items based on the logged in user's permissions. It is possible to set different text, tooltip, icon, etc. for a disabled button.
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:
AbstractJspActionFactory.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
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.
Field Summary | |
---|---|
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 |
onClick
|
private Permission |
visiblePermission
|
Constructor Summary | |
---|---|
PermissionButtonFactory()
Create a new factory instance. |
Method Summary | |
---|---|
ButtonAction[] |
getActions(InvokationContext context)
This method may be called one or several times for each request. |
private boolean |
hasPermission(ClientContext cc,
Item accepted,
Permission permission)
|
void |
setClazz(String clazz)
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 |
setIcon(String icon)
Set the icon to use in all cases. |
void |
setId(String id)
Set the ID of the button. |
void |
setItem(String item)
Set the item type to check the permission for. |
void |
setOnClick(String onClick)
|
void |
setStyle(String style)
Set the style to use in all cases. |
void |
setTitle(String title)
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 |
---|
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 id
private String onClick
private Permission visiblePermission
private Permission enabledPermission
private Item itemToCheck
private String enabledClazz
private String disabledClazz
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 PermissionButtonFactory()
Method Detail |
---|
public ButtonAction[] getActions(InvokationContext context)
ActionFactory
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 or null to
accept all itemspublic void setEnabledClazz(String clazz)
public void setDisabledClazz(String clazz)
public void setClazz(String clazz)
@VariableSetter @PathSetter public void setEnabledIcon(String icon)
@VariableSetter @PathSetter public void setDisabledIcon(String icon)
@VariableSetter @PathSetter public void setIcon(String icon)
public void setId(String id)
@VariableSetter public void setOnClick(String onClick)
public void setEnabledStyle(String style)
public void setDisabledStyle(String style)
public void setStyle(String style)
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)
private boolean hasPermission(ClientContext cc, Item accepted, Permission permission)
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |