org.sitemesh.webapp
Class WebAppContext

java.lang.Object
  extended by org.sitemesh.BaseSiteMeshContext
      extended by org.sitemesh.webapp.WebAppContext
All Implemented Interfaces:
SiteMeshContext

public class WebAppContext
extends BaseSiteMeshContext

SiteMesh SiteMeshContext implementation specifically for webapps running in a Servlet container. Makes HttpServletRequest, HttpServletResponse and ServletContext available to web-app specific SiteMesh components.

Author:
Joe Walnes, Mike Cannon-Brookes

Field Summary
static String CONTENT_KEY
          Key that the ContentProperty is stored under in the HttpServletRequest attribute.
static String CONTEXT_KEY
          Key that the WebAppContext is stored under in the HttpServletRequest attribute.
 
Constructor Summary
WebAppContext(String contentType, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext servletContext, ContentProcessor contentProcessor, ResponseMetaData metaData)
           
 
Method Summary
protected  void decorate(String decoratorPath, Content content, Writer out)
          Dispatches to another path to render a decorator.
protected  void dispatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String path)
          Dispatch to the actual path.
 String getContentType()
           
 String getPath()
          Get path of the page currently being displayed.
 javax.servlet.http.HttpServletRequest getRequest()
           
static String getRequestPath(javax.servlet.http.HttpServletRequest request)
           
 javax.servlet.http.HttpServletResponse getResponse()
           
 javax.servlet.ServletContext getServletContext()
           
 
Methods inherited from class org.sitemesh.BaseSiteMeshContext
decorate, getContentToMerge
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_KEY

public static final String CONTENT_KEY
Key that the ContentProperty is stored under in the HttpServletRequest attribute. It is "org.sitemesh.content.Content".


CONTEXT_KEY

public static final String CONTEXT_KEY
Key that the WebAppContext is stored under in the HttpServletRequest attribute. It is "org.sitemesh.SiteMeshContext".

Constructor Detail

WebAppContext

public WebAppContext(String contentType,
                     javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     javax.servlet.ServletContext servletContext,
                     ContentProcessor contentProcessor,
                     ResponseMetaData metaData)
Method Detail

getRequest

public javax.servlet.http.HttpServletRequest getRequest()

getResponse

public javax.servlet.http.HttpServletResponse getResponse()

getServletContext

public javax.servlet.ServletContext getServletContext()

getContentType

public String getContentType()

getPath

public String getPath()
Description copied from interface: SiteMeshContext
Get path of the page currently being displayed.


getRequestPath

public static String getRequestPath(javax.servlet.http.HttpServletRequest request)

decorate

protected void decorate(String decoratorPath,
                        Content content,
                        Writer out)
                 throws IOException
Dispatches to another path to render a decorator.

This path may anything that handles a standard request (e.g. Servlet, JSP, MVC framework, etc).

The end point can access the ContentProperty and SiteMeshContext by using looking them up as HttpServletRequest attributes under the keys CONTENT_KEY and CONTEXT_KEY respectively.

Specified by:
decorate in class BaseSiteMeshContext
Throws:
IOException

dispatch

protected void dispatch(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response,
                        String path)
                 throws javax.servlet.ServletException,
                        IOException
Dispatch to the actual path. This method can be overriden to provide different ways of dispatching (such as cross web-app).

Throws:
javax.servlet.ServletException
IOException


Copyright © 2011. All Rights Reserved.