org.apache.cocoon.generation
Class VelocityGenerator.ChainedContext

java.lang.Object
  extended byorg.apache.velocity.context.InternalContextBase
      extended byorg.apache.velocity.context.AbstractContext
          extended byorg.apache.velocity.VelocityContext
              extended byorg.apache.cocoon.generation.VelocityGenerator.ChainedContext
All Implemented Interfaces:
Cloneable, org.apache.velocity.context.Context, org.apache.velocity.context.InternalEventContext, org.apache.velocity.context.InternalHousekeepingContext, Serializable
Enclosing class:
VelocityGenerator

public static class VelocityGenerator.ChainedContext
extends org.apache.velocity.VelocityContext

Velocity context implementation specific to the Servlet environment.

It provides the following special features:

The internalGet(String key) method implements the following search order for objects:

  1. servlet request, servlet response, servlet session, servlet context
  2. toolbox
  3. local hashtable of objects (traditional use)
  4. servlet request attribues, servlet session attribute, servlet context attributes

The purpose of this class is to make it easy for web designer to work with Java servlet based web applications. They do not need to be concerned with the concepts of request, session or application attributes and the live time of objects in these scopes.

Note that the put() method always puts objects into the local hashtable.

Acknowledge: the source code is borrowed from the jakarta-velocity-tools project with slight modifications.

Author:
Albert Kwong, Geir Magnusson Jr., Gabe Sidler, Albert Kwong
See Also:
Serialized Form

Field Summary
static String APPLICATION
          Key to the servlet context object.
static String PARAMETERS
          Key to the servlet context object.
static String REQUEST
          Key to the HTTP request object.
static String RESPONSE
          Key to the HTTP response object.
static String SESSION
          Key to the HTTP session object.
 
Constructor Summary
VelocityGenerator.ChainedContext(org.apache.velocity.context.Context ctx, Request request, Response response, Context application, Parameters parameters)
          Default constructor.
 
Method Summary
 Object internalGet(String key)
          Looks up and returns the object with the specified key.
 
Methods inherited from class org.apache.velocity.VelocityContext
clone, internalContainsKey, internalGetKeys, internalPut, internalRemove
 
Methods inherited from class org.apache.velocity.context.AbstractContext
attachEventCartridge, containsKey, get, getChainedContext, getCurrentResource, getCurrentTemplateName, getEventCartridge, getKeys, getTemplateNameStack, icacheGet, icachePut, popCurrentTemplateName, pushCurrentTemplateName, put, remove, setCurrentResource
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST

public static final String REQUEST
Key to the HTTP request object.

See Also:
Constant Field Values

RESPONSE

public static final String RESPONSE
Key to the HTTP response object.

See Also:
Constant Field Values

SESSION

public static final String SESSION
Key to the HTTP session object.

See Also:
Constant Field Values

APPLICATION

public static final String APPLICATION
Key to the servlet context object.

See Also:
Constant Field Values

PARAMETERS

public static final String PARAMETERS
Key to the servlet context object.

See Also:
Constant Field Values
Constructor Detail

VelocityGenerator.ChainedContext

public VelocityGenerator.ChainedContext(org.apache.velocity.context.Context ctx,
                                        Request request,
                                        Response response,
                                        Context application,
                                        Parameters parameters)
Default constructor.

Method Detail

internalGet

public Object internalGet(String key)

Looks up and returns the object with the specified key.

See the class documentation for more details.

Parameters:
key - the key of the object requested
Returns:
the requested object or null if not found


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.