|
SilverStream eXtend Director 4.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Interface for storing and retrieving information about the user's environment. The context has the user's ID, the user's session, response and request objects appropriate to the current user agent or browser.
The context object exists for the duration of a request. In a component, the request ends when getComponentData() returns. With each new request, the portal instantiates a new context object.
Information that persists between requests is stored in the EbiSession object, which is available from the context. The session includes a "whiteboard" that holds values that a component needs to keep available. You give each whiteboard value a key, which you use to retrieve the value. If there is no session, the portal creates a session-independent whiteboard for storing your persistent data. When another request occurs, the session and whiteboard become part of the new context object and are passed back to the component.
Different parts of Director use different types of context objects.
In a portal component (EbiPortalComponent),
a portal context object is passed to the getComponentData()
method. To work with rules in a portal component,
you can get a rule context (EbiContext)
from the portal context.
See EboFactory.createEbiContext(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse).
In other situations, you can get a portal context object from
EboFactory.
You can get a generic context object
from EboFactory.
Generic context objects do not persist; they provide
access to methods that require a context and security information,
but they do not have
the full functionality of an HTTP-based portal context.
| Method Summary | |
EbiContext |
cloneCopy(EbiContext context)
Copies the common data from this context object to another. |
Enumeration |
getAttributeNames()
Gets an Enumeration of the whiteboard keys that are defined in the session. |
Map |
getBrowserInfo()
Returns information about the current user agent. |
EbiRequest |
getEbiRequest()
Gets the request object associated with the session. |
EbiResponse |
getEbiResponse()
Gets the response object associated with the session. |
EbiSession |
getEbiSession()
Gets a portal session object. |
EbiSession |
getEbiSession(EJBContext ctx)
Gets a portal session object using information passed in from an EJB context object. |
EbiWhiteboard |
getEbiWhiteboard()
Gets the whiteboard for the session. |
EJBContext |
getEJBContext()
Gets the EJB context stored in this EbiContext object. |
String |
getException()
No information. |
Locale |
getLocale()
Gets information about the user's language and geographical location. |
Principal |
getPrincipal()
Deprecated. |
Map |
getTemporaryData()
Gets all the temporary key/value pairs stored in the context. |
Object |
getTemporaryValue(Object key)
Gets a value that has been stored in the context object for the current request. |
Object |
getValue(String key)
Gets the value associated with the specified whiteboard key. |
Object |
getValue(String key,
Object dft)
Gets either the value associated with the specified whiteboard key or a default value. |
String[] |
getValueNames()
Deprecated. |
boolean |
hasSession()
Checks if the context has a reference to an HTTP session. |
boolean |
hasValue(String key)
Checks whether the specified key has a value on the whiteboard. |
boolean |
isNewSession()
Checks if this is the first request of the session. |
void |
removeAllValues()
Removes all values and their keys from the whiteboard. |
void |
removeValue(String key)
Removes a value associated with the specified key from the whiteboard. |
void |
setEbiRequest(EbiRequest request)
No information available |
void |
setEbiResponse(EbiResponse response)
No information available |
void |
setEbiSession(EbiSession ebiSession)
Associates a session with the context object. |
void |
setEJBContext(EJBContext context)
Sets the EJB context in this EbiContext object. |
void |
setException(String exception)
No information. |
void |
setTemporaryValue(Object key,
Object value)
Sets a value in the context object for the current request. |
void |
setValue(String key,
Object value)
Sets a value on the whiteboard. |
| Method Detail |
public EbiRequest getEbiRequest()
In the processRequest() method of a component, you can get
parameters that the component set by calling these methods:
For example, FORM_LIST_NAME is a constant whose value is the name of an HTML SELECT control on a form:
String selected = context.getEbiRequest().getParameter(FORM_LIST_NAME);
public EbiResponse getEbiResponse()
You don't usually need to get the response object. You can use methods of EbiContext to get and set its property values, such as:
public void setEbiResponse(EbiResponse response)
public void setEbiRequest(EbiRequest request)
public Map getBrowserInfo()
Applying the toString() method to the Map object generates text like this:
{BrowserMinorVer=01, BrowserMajorVer=5, Platform=Windows NT, BrowserName=MSIE}
This code uses constants of EboRequestHelper for the browser information keys and gets the values for each key. The getMapValue() method appends each key and value to a string:
java.util.Map browserinfo = context.getBrowserInfo();
s = reportMap(browserinfo);
private String report(java.util.Map map)
{
String s = "";
String val = "";
String key = "";
key = EboRequestHelper.BROWSER_MAJOR_VER;
getMapValue(map, key, s);
key = EboRequestHelper.BROWSER_MINOR_VER;
s = getMapValue(map, key, s);
key = EboRequestHelper.BROWSER_NAME;
s = getMapValue(map, key, s);
key = EboRequestHelper.PLATFORM;
s = getMapValue(map, key, s);
return s;
}
private String getMapValue(Map map, String key, String s)
{
String val;
if (map.containsKey(key))
{
val = (String) map.get(key);
s = s + key + " " + val + "\n";
}
return s;
}
This code gets the browser name and compares it to the value for Microsoft Internet Explorer:
if (map.get(EboRequestHelper.BROWSER_NAME).equals(
EboRequestHelper.BROWSER_MSIE))
{ ... }
public Object getTemporaryValue(Object key)
In contrast to whiteboard values which are stored in the session, temporary values are only available until the request ends; that is, when getComponentData() returns the generated content to the portal's Presentation Manager. You get and set whiteboard values with the getValue() and setValue() methods.
key - An object that identifies the temporary value.EbiContext.setTemporaryValue( Object key, Object value ),
EbiContext.getValue( String key, Object dft ),
EbiContext.setValue( String key, Object value )public Map getTemporaryData()
public void setTemporaryValue(Object key,
Object value)
To store values that persist during the session, call setValue(), which stores them on the whiteboard.
key - An Object that identifies the temporary value. Temporary keys
are not limited to Strings.value - An Object that is the stored value.EbiContext.getTemporaryValue( Object key ),
EbiContext.setValue(String, Object)public void setEJBContext(EJBContext context)
context - An EJB context.public EJBContext getEJBContext()
public Object getValue(String key)
To return a default value instead of null when the whiteboard key does not exist, use the 2-argument version of getValue().
key - The name of the whiteboard key.EbiContext.getValue( String key, Object dft )
public Object getValue(String key,
Object dft)
If the key does not exist, this version of getValue() returns the specified default value.
key - The name of the whiteboard key.dft - An object to be returned when the key value is null or does
not exist.EbiContext.getValue( String key )public String[] getValueNames()
EbiContext.getValue( String key ),
EbiContext.getValue( String key, Object dft ),
EbiContext.getAttributeNames()public Enumeration getAttributeNames()
EbiContext.getValue( String key ),
EbiContext.getValue( String key, Object dft )
public void setValue(String key,
Object value)
EbiContext.key - A String that identifies the stored value.value - An Object that is the value being stored.EbiContext.getValue( String key),
EbiContext.getValue( String key, Object dft )public boolean hasValue(String key)
public void removeAllValues()
public void removeValue(String key)
key - A String that identifies a value on the whiteboard.public EbiWhiteboard getEbiWhiteboard()
EbiContext.public String getException()
public void setException(String exception)
public Locale getLocale()
See java.util.Locale for more information.
public EbiSession getEbiSession()
public EbiSession getEbiSession(EJBContext ctx)
ctx - An EJB context object.public boolean hasSession()
public boolean isNewSession()
public void setEbiSession(EbiSession ebiSession)
This example assigns a session to a new context object. An EbiSession
object is passed to the initialize() method of a component. This code in
initialize() gets a context object from EboFactory and associates the
session with it. A context object with user information is required for
many EbiContentManager methods.
EbiContext context =
com.sssw.fw.factory.EboFactory.createEbiContext(null);
context.setEbiSession(session);
EbiContentManager contentMgr = (EbiContentManager)
portal.getPortalManagerInterface(EbiPortalConstants.PORTAL_CONTENT_MGR);
ebiSession - A portal session.
public Principal getPrincipal()
throws EboException
EbiSecurityAclDelegate.addPrincipalsToAcl(EbiContext context,
java.lang.String elementIID,
java.lang.String elementType,
java.lang.String right,
java.security.Principal[] principals)public EbiContext cloneCopy(EbiContext context)
context - The context that will have its data updated.
|
SilverStream eXtend Director 4.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||