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
 
Fields inherited from class org.thymeleaf.context.AbstractContext
EXEC_INFO_VARIABLE_NAME
 
Constructor Summary
WebContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext servletContext)
           Create an instance without specifying a locale.
WebContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext servletContext, Locale locale)
           Create an instance specifying a locale.
WebContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext servletContext, Locale locale, 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()
          Deprecated. Get attributes from the ServletContext object directly instead. Will be removed in 3.0.
 javax.servlet.http.HttpServletRequest getHttpServletRequest()
           Returns the HttpServletRequest object associated with the request this context has been created for.
 javax.servlet.http.HttpServletResponse getHttpServletResponse()
           Returns the HttpServletResponse 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()
          Deprecated. Get attributes from the HttpServletRequest object directly instead. Will be removed in 3.0.
 VariablesMap<String,String[]> getRequestParameters()
          Deprecated. Get parameters from the HttpServletRequest object directly instead. Will be removed in 3.0.
 javax.servlet.ServletContext getServletContext()
           Returns the ServletContext object associated with the web application.
 VariablesMap<String,Object> getSessionAttributes()
          Deprecated. Get attributes from the HttpSession object directly instead. Will be removed in 3.0.
 
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
 

Constructor Detail

WebContext

public WebContext(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response,
                  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.
response - the HttpServletResponse that this context will be related to.
servletContext - the servlet context object
Since:
2.0.9

WebContext

public WebContext(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response,
                  javax.servlet.ServletContext servletContext,
                  Locale locale)

Create an instance specifying a locale.

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

WebContext

public WebContext(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response,
                  javax.servlet.ServletContext servletContext,
                  Locale locale,
                  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.
response - the HttpServletResponse 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. Can be null if no variables are to added.
Since:
2.0.9
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.

getHttpServletResponse

public javax.servlet.http.HttpServletResponse getHttpServletResponse()
Description copied from interface: IWebContext

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

Specified by:
getHttpServletResponse in interface IWebContext
Returns:
the HTTP servlet response.

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

@Deprecated
public VariablesMap<String,String[]> getRequestParameters()
Deprecated. Get parameters from the HttpServletRequest object directly instead. Will be removed in 3.0.

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

@Deprecated
public VariablesMap<String,Object> getRequestAttributes()
Deprecated. Get attributes from the HttpServletRequest object directly instead. Will be removed in 3.0.

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

@Deprecated
public VariablesMap<String,Object> getSessionAttributes()
Deprecated. Get attributes from the HttpSession object directly instead. Will be removed in 3.0.

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

@Deprecated
public VariablesMap<String,Object> getApplicationAttributes()
Deprecated. Get attributes from the ServletContext object directly instead. Will be removed in 3.0.

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 © 2014 The THYMELEAF team. All Rights Reserved.