net.sf.colle.web
Class Context

java.lang.Object
  extended bynet.sf.colle.web.Context

public class Context
extends Object

Provides the context of a response to a request. Handles common requests such as getting the operator User object and performing an XSL translation. Created: 21 Dec 2001

Version:
$Revision: 1.10 $, $Date: 2004/11/11 06:41:04 $
Author:
Dwayne Schultz

Constructor Summary
(package private) Context(HttpServletRequest pxRequest, HttpServletResponse pxResponse, ServletContext pxServletContext, String psActionParameter, String psControllerFolder, String psControllerName, boolean pbDebug)
          Constructs a control manager for a known controller.
(package private) Context(HttpServletRequest pxRequest, HttpServletResponse pxResponse, ServletContext pxServletContext, Transformation pxTransformation, boolean pbDebug)
          Constructs a control manager for a standalone manager.
 
Method Summary
 void addDataPath(String psDataPath)
          Causes data objects being mapped through this context to include additional information if they are found in the provided data path or higher.
 void closeWindow()
          Closes the current browser window.
 String getActionParameter()
          Gets the action parameter that decided which action of a contoller was called.
 Locale getLocale()
          Returns the locale of the current session if one exists.
 Object getOperator()
          Returns the operator who is currently logged in making this request.
 HttpServletRequest getRequest()
          Returns the request.
 HttpServletResponse getResponse()
          Returns the response.
 org.jdom.Document getResponseDocument()
          Returns the response document which allows the controller to modify it.
 ServletContext getServletContext()
          Returns the servlet context.
 Transformation getTransformation()
          Returns the transformation that is currently set.
(package private) static void init(ServletConfig pxConfig)
           
 boolean isOperaterSet()
          Returns true if a non-null operator has been set with the setOperator method.
 void map(org.jdom.Element pxElement, String psName, Object pxObject)
          Maps the interface into the response document.
 void map(String psName, Object pxObject)
          Maps the interface into the root of the response document.
 void mapCollection(org.jdom.Element pxElement, String psName, Collection pxCollection)
          Maps the collection into the response document.
 void mapCollection(String psName, Collection pxCollection)
          Maps the collection into the root of the response document.
 void redirectToLoginReferrer(String psBackupLocation)
          Sends a redirect to the client that sends the client back to the page they requested before they were redirected to the login page.
 void setContentType(String psContentType)
          Sets the content type of the response.
 void setLocale(Locale pxLocale)
          Sets the locale for the current user, creating a session if required.
 void setOperator(Object pxOperator)
          Sets the operator.
 Transformation setTransformation(String psTransformation)
          Set the transformation that will be eventually used to transform the output to the client.
 void transform()
          Sends the output to the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Context

Context(HttpServletRequest pxRequest,
        HttpServletResponse pxResponse,
        ServletContext pxServletContext,
        String psActionParameter,
        String psControllerFolder,
        String psControllerName,
        boolean pbDebug)
Constructs a control manager for a known controller.


Context

Context(HttpServletRequest pxRequest,
        HttpServletResponse pxResponse,
        ServletContext pxServletContext,
        Transformation pxTransformation,
        boolean pbDebug)
  throws IOException
Constructs a control manager for a standalone manager.

Method Detail

init

static void init(ServletConfig pxConfig)

closeWindow

public void closeWindow()
                 throws IOException
Closes the current browser window. This sends a html page to the client with javascript that closes the window. If the current window was not opened by javascript a message will pop up asking the user if it is ok to close the window. Do not call this method after sending a response. Do not attempt to send a response after calling this method.

Throws:
IOException

getRequest

public HttpServletRequest getRequest()
Returns the request.


getResponse

public HttpServletResponse getResponse()
Returns the response.


getServletContext

public ServletContext getServletContext()
Returns the servlet context.


getResponseDocument

public org.jdom.Document getResponseDocument()
Returns the response document which allows the controller to modify it.


getLocale

public Locale getLocale()
Returns the locale of the current session if one exists. Otherwise returns the default locale.


setLocale

public void setLocale(Locale pxLocale)
Sets the locale for the current user, creating a session if required.


isOperaterSet

public boolean isOperaterSet()
                      throws IOException
Returns true if a non-null operator has been set with the setOperator method.

Throws:
IOException

getOperator

public final Object getOperator()
                         throws IOException
Returns the operator who is currently logged in making this request. If there is no operator the user will be directed to the system login page defined by the system property net.sf.colle.web.loginPage.

Throws:
IOException

redirectToLoginReferrer

public void redirectToLoginReferrer(String psBackupLocation)
                             throws IOException
Sends a redirect to the client that sends the client back to the page they requested before they were redirected to the login page. If they were not requesting another page or if they the login referrer was external to this system, then the client will be directed to the specified location.

Throws:
IOException

setOperator

public void setOperator(Object pxOperator)
Sets the operator. Once this object is set the user will be authenticated as long as their session is valid.

Parameters:
pxOperator - operator object, may be null to log-out the operator

getTransformation

public Transformation getTransformation()
Returns the transformation that is currently set. May return null if no default transformation exists and setTransformation() hasn't been called.


setTransformation

public final Transformation setTransformation(String psTransformation)
                                       throws IOException
Set the transformation that will be eventually used to transform the output to the client. This method should be called before mapping any objects because the transformation determines how deeply the objects are mapped through processing instructions.

Throws:
IOException

addDataPath

public void addDataPath(String psDataPath)
Causes data objects being mapped through this context to include additional information if they are found in the provided data path or higher.

Parameters:
psDataPath - data path to requested data as seen in the response document.

getActionParameter

public String getActionParameter()
Gets the action parameter that decided which action of a contoller was called. This will be null in the defaultAction.


setContentType

public void setContentType(String psContentType)
Sets the content type of the response. Do not call getResponse().setContentType() or your content type will be overwritten by the stylesheet's output method and media-type. The value set here takes precedence over the stylesheet's output method and media-type. If the content type is set to null the stylesheet's output method and media- type will be used.


map

public void map(String psName,
                Object pxObject)
Maps the interface into the root of the response document.

Parameters:
psName - name the first element tag should be called
pxObject - object being mapped

mapCollection

public void mapCollection(String psName,
                          Collection pxCollection)
Maps the collection into the root of the response document.

Parameters:
psName - name the first element tag should be called
pxCollection - collection being mapped

map

public void map(org.jdom.Element pxElement,
                String psName,
                Object pxObject)
Maps the interface into the response document.

Parameters:
pxElement - node to map into
psName - name the first element tag should be called
pxObject - object being mapped

mapCollection

public void mapCollection(org.jdom.Element pxElement,
                          String psName,
                          Collection pxCollection)
Maps the collection into the response document.

Parameters:
pxElement - node to map into
psName - name the first element tag should be called
pxCollection - collection being mapped

transform

public void transform()
               throws IOException
Sends the output to the client.

Throws:
IOException