| com.jcorporate.expresso.core.controller.session.PersistentSession
All known Subclasses: com.jcorporate.expresso.core.controller.session.HTTPPersistentSession, com.jcorporate.expresso.core.controller.session.SimplePersistentSession,
PersistentSession | public interface PersistentSession extends Serializable(Code) | | A PersistentSession is simply a place to stash some values between
states of a controller object. Different environments may employ different
ways of doing this - the simplest being SimplePersistentSession, where a hashtable does
all the required work.
The typical way to use a PersistentSession is within a controller object
as part of your state handler. You do not instantiate it directly, the controller
framework instantiates the appropriate kind of session for you. [Unless you're directly
creating a controller yourself, such as in a command line environment, in which case, you would
set the session object at say, SimplePersistentSession... if you're getting confused at what
is meant by this, ignore it.]
Example Usage:
void protected runMyState(ControllerRequest request, ControllerResponse response) throws ControllerException {
PersistentSesssion session = request.getSession();
//Set an attribute that exists only for the current request.
session.setAttribute("RequestAttribute", "Controller Was Executed");
//Set an attribute that exists for the entire session
session.setPersistentAttribute("SessionAttribute","Customer Has Logged In");
//Set an attribute that persists across requests. [In HTTP sets a cookie]
session.setClientAttribute("ACookie", "Cookie Data That May Get Encrypted");
author: Michael Nash since: Expresso 4.0 |
getAttribute | public Object getAttribute(String attribName)(Code) | | Retrieves the object from the request context.
Parameters: attribName - the name of the object to retrieve the object or null if it doesn't exist. |
getAttributeNames | public Enumeration getAttributeNames()(Code) | | Retrieves all attribute names in the request context.
java.util.Enumeration |
getClientAttribute | public String getClientAttribute(String attribName)(Code) | | Retrieves a value of a cookie set on the client's system. It also
decrypts the value with the password you set up in your expresso-config.xml
file.
Parameters: attribName - the name of the cookie to retrieve java.lang.String the value of the cookie or null if the cookie doesn't exist. |
getPeristentAttributeNames | public Enumeration getPeristentAttributeNames()(Code) | | Retrieves all attribute names from the session context.
java.util.Enumeration |
getPersistentAttribute | public Object getPersistentAttribute(String attribName)(Code) | | Retrieves the object from the session context.
Parameters: attribName - the name of the object to retrieve the object or null if it doesn't exist. |
invalidate | public void invalidate()(Code) | | Clear out the session. Invalidates the entire session.
|
removeAttribute | public void removeAttribute(String attribName)(Code) | | Clears an attribute from the request context
Parameters: attribName - the name of the attribute to remove. |
removePersistentAttribute | public void removePersistentAttribute(String attribName)(Code) | | Clears an attribute from the session context
Parameters: attribName - the name of the attribute to remove. |
setAttribute | public void setAttribute(String attribName, Object attribValue)(Code) | | Sets an attribute that is valid for the duration of the request.
Parameters: attribName - The name of the object you wish to set. Parameters: attribValue - the object you want to set. |
setClientAttribute | public void setClientAttribute(String attribName, String attribValue)(Code) | | If in HTTP environment, it sets an encrypted cookie to the client.
Parameters: attribName - the name of the attribute to Parameters: attribValue - the value of the attribute to set. |
setPersistentAttribute | public void setPersistentAttribute(String attribName, Object attribValue)(Code) | | Saves an attribute to the actual session, rather than simply the response.
Use this for storing objects between requests, but only use it with care
since the extra memory used may bog down systems under high load.
Parameters: attribName - the name of the attribute to set Parameters: attribValue - a Serializable java object. See Also: java.io.Serializable |
|
|