public class ClientContext
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.Object> |
attributes |
private DbControl |
dc |
private java.lang.Object |
item |
private SessionControl |
sc |
Modifier | Constructor and Description |
---|---|
|
ClientContext()
Create a new context with no session or current item.
|
|
ClientContext(DbControl dc)
Create a new context with a DbControl.
|
|
ClientContext(DbControl dc,
java.lang.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,
java.lang.Object item) |
|
ClientContext(SessionControl sc,
java.lang.Object item)
Create a new context with a session and item but no DbControl.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getAttribute(java.lang.String name)
Get an attribute of the context.
|
java.lang.Object |
getCurrentItem()
Get the currently active item.
|
DbControl |
getDbControl()
Get the current DbControl.
|
SessionControl |
getSessionControl()
Get the current session control.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Set an attribute of the context.
|
void |
setCurrentItem(java.lang.Object item)
Set the currently active item.
|
private final SessionControl sc
private final DbControl dc
private java.lang.Object item
private java.util.Map<java.lang.String,java.lang.Object> attributes
public ClientContext()
public ClientContext(SessionControl sc)
sc
- The current sessionpublic ClientContext(SessionControl sc, java.lang.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, java.lang.Object item)
setCurrentItem(Object)
to change
the item.dc
- An open DbControlitem
- The current itemprotected ClientContext(SessionControl sc, DbControl dc, java.lang.Object item)
public SessionControl getSessionControl()
public DbControl getDbControl()
DbControl.close()
or DbControl.commit()
.public java.lang.Object getCurrentItem()
public void setCurrentItem(java.lang.Object item)
item
- The item that is the current itempublic java.lang.Object getAttribute(java.lang.String name)
name
- The name of the attributepublic void setAttribute(java.lang.String name, java.lang.Object value)
name
- The name of the attributevalue
- The value, if null the attribute is removed