|
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.util.extensions.ClientContext
public class ClientContext
Keeps information about the current context in the client application that extensions can use to decide what actions to generate. It is, for example, possible to check the permissions of logged in user and enable/disable certain actions if a condition is not met. Or, the extension may inspect the current item and decide if the extension can be used on that item or not.
The current context is passed to an ActionFactory
twice, first
to check if an extension should be enabled or not
with the ActionFactory.prepareContext(InvokationContext)
method. This method also allows an extension to write
back information to the context. This may, for example,
include information about which Javascript scripts to import
or which stylesheets to load. The prepareContext
method is only called once for each use of an extension.
The second time is when calling the ActionFactory.getActions(InvokationContext)
method. This method can
be called multiple times. For example, if an extension point
is in a list context, the getActions
method may
be called one time for each item in the list. If so, the
getCurrentItem()
returns the currently active item.
Client applications may subclass this object to provide more
information about the client environment. See, for example,
the JspContext
object.
Field Summary | |
---|---|
private Map<String,Object> |
attributes
|
private DbControl |
dc
|
private Object |
item
|
private SessionControl |
sc
|
Constructor Summary | |
---|---|
|
ClientContext(DbControl dc)
Create a new context with a DbControl. |
|
ClientContext(DbControl dc,
Object item)
Create a new context with a DbControl and item. |
|
ClientContext(SessionControl sc)
Create a new context with a session and no DbControl. |
protected |
ClientContext(SessionControl sc,
DbControl dc,
Object item)
|
|
ClientContext(SessionControl sc,
Object item)
Create a new context with a session and item but no DbControl. |
Method Summary | |
---|---|
Object |
getAttribute(String name)
Get an attribute of the context. |
Object |
getCurrentItem()
Get the currently active item. |
DbControl |
getDbControl()
Get the current DbControl. |
SessionControl |
getSessionControl()
Get the current session control. |
void |
setAttribute(String name,
Object value)
Set an attribute of the context. |
void |
setCurrentItem(Object item)
Set the currently active item. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final SessionControl sc
private final DbControl dc
private Object item
private Map<String,Object> attributes
Constructor Detail |
---|
public ClientContext(SessionControl sc)
sc
- The current sessionpublic ClientContext(SessionControl sc, Object item)
setCurrentItem(Object)
to change
the item.
sc
- The current sessionitem
- The current itempublic ClientContext(DbControl dc)
dc
- An open DbControlpublic ClientContext(DbControl dc, Object item)
setCurrentItem(Object)
to change
the item.
dc
- An open DbControlitem
- The current itemprotected ClientContext(SessionControl sc, DbControl dc, Object item)
Method Detail |
---|
public SessionControl getSessionControl()
public DbControl getDbControl()
DbControl.close()
or DbControl.commit()
.
public Object getCurrentItem()
public void setCurrentItem(Object item)
item
- The item that is the current itempublic Object getAttribute(String name)
name
- The name of the attribute
public void setAttribute(String name, Object value)
name
- The name of the attributevalue
- The value, if null the attribute is removed
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |