org.thymeleaf.context
Class WebContext

Object
  extended by org.thymeleaf.context.AbstractContext
      extended by org.thymeleaf.context.WebContext
All Implemented Interfaces:
IContext, IWebContext

public class WebContext
extends AbstractContext
implements IWebContext

Standard implementation for the IWebContext interface.

This IContext implementation uses a WebContextExecutionInfo object as its IContextExecutionInfo implementation.

Since:
1.0
Author:
Daniel Fernández, Josh Long

Field Summary
static String APPLICATION_VARIABLE_NAME
           Name of the context variable that contains the application (servlet context) attributes.
static String PARAM_VARIABLE_NAME
           Name of the context variable that contains the request parameters.
static String SESSION_VARIABLE_NAME
           Name of the context variable that contains the session attributes.
 
Fields inherited from class org.thymeleaf.context.AbstractContext
EXEC_INFO_VARIABLE_NAME
 
Constructor Summary
WebContext(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext servletContext)
           Create an instance without specifying a locale.
WebContext(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext servletContext, java.util.Locale locale)
           Create an instance specifying a locale.
WebContext(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext servletContext, java.util.Locale locale, java.util.Map<String,?> variables)
           Create an instance specifying a locale and an initial set of context variables.
 
Method Summary
protected  IContextExecutionInfo buildContextExecutionInfo(String templateName)
           Creates the specific instance of IContextExecutionInfo to be added to the context as the execInfo variable.
 VariablesMap<String,Object> getApplicationAttributes()
           Returns a VariablesMap object with all the attributes associated with the ServletContext object linked to the HttpServletRequest used for creating the context.
 javax.servlet.http.HttpServletRequest getHttpServletRequest()
           Returns the HttpServletRequest object associated with the request this context has been created for.
 javax.servlet.http.HttpSession getHttpSession()
           Returns the HttpSession object associated with the request this context has been created for.
 VariablesMap<String,Object> getRequestAttributes()
           Returns a VariablesMap object with all the attributes associated with the HttpServletRequest used for creating the context.
 VariablesMap<String,String[]> getRequestParameters()
           Returns a VariablesMap object with all the parameters associated with the HttpServletRequest used for creating the context.
 javax.servlet.ServletContext getServletContext()
           Returns the ServletContext object associated with the web application.
 VariablesMap<String,Object> getSessionAttributes()
           Returns a VariablesMap object with all the attributes associated with the HttpSession object linked to the HttpServletRequest used for creating the context.
 
Methods inherited from class org.thymeleaf.context.AbstractContext
addContextExecutionInfo, clearVariables, getLocale, getVariables, setLocale, setVariable, setVariables
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.thymeleaf.context.IContext
addContextExecutionInfo, getLocale, getVariables
 

Field Detail

PARAM_VARIABLE_NAME

public static final String PARAM_VARIABLE_NAME

Name of the context variable that contains the request parameters.

See Also:
Constant Field Values

SESSION_VARIABLE_NAME

public static final String SESSION_VARIABLE_NAME

Name of the context variable that contains the session attributes.

See Also:
Constant Field Values

APPLICATION_VARIABLE_NAME

public static final String APPLICATION_VARIABLE_NAME

Name of the context variable that contains the application (servlet context) attributes.

See Also:
Constant Field Values
Constructor Detail

WebContext

public WebContext(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.ServletContext servletContext)

Create an instance without specifying a locale. Using this constructor, the default locale (Locale.getDefault()) will be used.

Parameters:
request - the HttpServletRequest that this context will be related to.
servletContext - the servlet context object
Since:
1.1.3

WebContext

public WebContext(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.ServletContext servletContext,
                  java.util.Locale locale)

Create an instance specifying a locale.

Parameters:
request - the HttpServletRequest that this context will be related to.
servletContext - the servlet context object
locale - the locale to be used.
Since:
1.1.3

WebContext

public WebContext(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.ServletContext servletContext,
                  java.util.Locale locale,
                  java.util.Map<String,?> variables)

Create an instance specifying a locale and an initial set of context variables.

Parameters:
request - the HttpServletRequest that this context will be related to.
servletContext - the servlet context object
locale - the locale to be used.
variables - the initial set of context variables.
Since:
1.1.3
Method Detail

getHttpServletRequest

public javax.servlet.http.HttpServletRequest getHttpServletRequest()
Description copied from interface: IWebContext

Returns the HttpServletRequest object associated with the request this context has been created for.

Specified by:
getHttpServletRequest in interface IWebContext
Returns:
the HTTP servlet request.

getHttpSession

public javax.servlet.http.HttpSession getHttpSession()
Description copied from interface: IWebContext

Returns the HttpSession object associated with the request this context has been created for.

Specified by:
getHttpSession in interface IWebContext
Returns:
the HTTP session.

getServletContext

public javax.servlet.ServletContext getServletContext()
Description copied from interface: IWebContext

Returns the ServletContext object associated with the web application.

Specified by:
getServletContext in interface IWebContext
Returns:
the servlet context.

getRequestParameters

public VariablesMap<String,String[]> getRequestParameters()
Description copied from interface: IWebContext

Returns a VariablesMap object with all the parameters associated with the HttpServletRequest used for creating the context.

Specified by:
getRequestParameters in interface IWebContext
Returns:
the maps of request parameters.

getRequestAttributes

public VariablesMap<String,Object> getRequestAttributes()
Description copied from interface: IWebContext

Returns a VariablesMap object with all the attributes associated with the HttpServletRequest used for creating the context.

Specified by:
getRequestAttributes in interface IWebContext
Returns:
the maps of request attributes.

getSessionAttributes

public VariablesMap<String,Object> getSessionAttributes()
Description copied from interface: IWebContext

Returns a VariablesMap object with all the attributes associated with the HttpSession object linked to the HttpServletRequest used for creating the context.

Specified by:
getSessionAttributes in interface IWebContext
Returns:
the maps of session attributes.

getApplicationAttributes

public VariablesMap<String,Object> getApplicationAttributes()
Description copied from interface: IWebContext

Returns a VariablesMap object with all the attributes associated with the ServletContext object linked to the HttpServletRequest used for creating the context.

Specified by:
getApplicationAttributes in interface IWebContext
Returns:
the maps of application attributes.

buildContextExecutionInfo

protected IContextExecutionInfo buildContextExecutionInfo(String templateName)
Description copied from class: AbstractContext

Creates the specific instance of IContextExecutionInfo to be added to the context as the execInfo variable.

Specified by:
buildContextExecutionInfo in class AbstractContext
Parameters:
templateName - the name of the template being executed
Returns:
the execution info object


Copyright © 2012 The THYMELEAF team. All Rights Reserved.