|
Novell exteNd Director 5.2 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
EbiContext stores information about the user's environment. It 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.
The session and whiteboard persist between requests. When another request occurs, these objects become part of the new context object and passed back to the component.
In a portal component, a context object is passed to the getComponentData() method. In other situations, you can get a portal context object from EboPortalFactory. You can get a generic context object from com.sssw.fw.factory.EboFactory.
Method Summary | |
EbiContext |
cloneCopy(EbiContext context)
Copy's the common data from one context 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. |
String |
getContextName()
Returns the context name associated with the web applications context |
EbiRequest |
getEbiRequest()
Gets the request object associated with the context. |
EbiResponse |
getEbiResponse()
Gets the response object associated with the context. |
EbiSession |
getEbiSession()
Gets a portal session object. |
EbiSession |
getEbiSession(com.sssw.fw.api.EJBContext ctx)
Gets a portal session object using the information passed in from an EJB context. |
EbiWhiteboard |
getEbiWhiteboard()
The whiteboard is a wrapper of the underlying session |
EJBContext |
getEJBContext()
Gets EJB context stored in this EbiContext. |
String |
getException()
Deprecated. |
Locale |
getLocale()
Gets information about the user's language and geographical location. |
Principal |
getPrincipal()
Deprecated. EboDirectoryHelper.getEbiRealmUser(EbiContext) |
Map |
getTemporaryData()
This method returns the temporary key: value pair, stored in the context, as a map. |
Object |
getTemporaryValue(Object key)
Gets a value that has been stored in context object for the current request. |
Object |
getValue(String key)
Returns the value associated with the specified whiteboard key. |
Object |
getValue(String key,
Object dft)
Returns the value associated with the specified whiteboard key or a default value. |
String[] |
getValueNames()
Deprecated. |
boolean |
hasSession()
Deprecated. |
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)
Deprecated. (since v5.0) |
void |
setEbiResponse(EbiResponse response)
Deprecated. (since v5.0) |
void |
setEbiSession(EbiSession ebiSession)
Associates a session with the context object. |
void |
setEJBContext(com.sssw.fw.api.EJBContext context)
Deprecated. (since v5.0) |
void |
setException(String exception)
Deprecated. |
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 String getContextName()
The context name is the unique name given to the web application. The context name will be null if the EbiContext object is not create with the context name reference. For example the context will be proper set when using:
The context name is determined by checking the display name of the web application. If this is null then the web application's init-param "context-name" is used.com.sssw.fw.factory.EboFactory.createEbiContext(HttpServletRequest,HttpServletResponse,ServletContext)
or
com.sssw.fw.factory.EboFactory.createEbiContext(RenderRequest,RenderResponse,PortletContext)
or
com.sssw.fw.factory.EboFactory.createEbiContext(ActionRequest,ActionResponse,PortletContext)
public EbiRequest getEbiRequest()
EbiRequest
for
further details
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);
EbiRequest
public EbiResponse getEbiResponse()
EbiRequest
for
further details
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:
EbiResponse
public void setEbiResponse(EbiResponse response)
For example:
com.sssw.fw.factory.EboFactory#createEbiContext(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
response
- public void setEbiRequest(EbiRequest request)
For example:
com.sssw.fw.factory.EboFactory#createEbiContext(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
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 available until the request ends and 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 valueEbiContext.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().
key
- an Object that identifies the temporary value. Temporary keys
are not limited to Strings.value
- an Object that is the stored valueEbiContext.getTemporaryValue( Object key )
,
EbiContext.setValue(String, Object)
public void setEJBContext(com.sssw.fw.api.EJBContext context)
This method should not be exposed to the API, do not use.
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 getValue(String, Object).
key
- the name of the whiteboard keyEbiContext.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 keydft
- an object to be returned when the key value is null or does
not existEbiContext.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 valuevalue
- an Object that is the value being storedEbiContext.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 whiteboardpublic EbiWhiteboard getEbiWhiteboard()
Gets the whiteboard for the session. The whiteboard contains information
stored by various applications. Each value is accessed by its key. For a
definition of the whiteboard, see EbiWhiteboard
.
public String getException()
public void setException(String exception)
public Locale getLocale()
If the underlying request object does not carry a locale then the systems
default locale is used. See java.util.Locale
for more information.
public EbiSession getEbiSession()
EbiSessionManager#getEbiSession()
public EbiSession getEbiSession(com.sssw.fw.api.EJBContext ctx)
EbiSessionManager#getEbiEJBSession(javax.ejb.EJBContext)
public boolean hasSession()
EbiRequest.getSession()
public boolean isNewSession()
EbiRequest.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 content manager 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 sessionpublic Principal getPrincipal() throws com.sssw.fw.api.EboException
EboDirectoryHelper.getEbiRealmUser(EbiContext)
public EbiContext cloneCopy(EbiContext context)
Common Data includes
context
- The context that will have its data updated
|
Novell exteNd Director 5.2 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |