|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.velocity.tools.ToolContext org.apache.velocity.tools.view.ViewToolContext
public class ViewToolContext
ToolContext
implementation specific to the servlet environment.
It provides the following special features:
The get(String key)
method implements the following search order
for objects:
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 lifetime of objects in these scopes.
Note that the put() method always puts objects into the local map and does not allow tools or servlet classes to be overridden.
Field Summary | |
---|---|
private javax.servlet.ServletContext |
application
|
private javax.servlet.http.HttpServletRequest |
request
|
private javax.servlet.http.HttpServletResponse |
response
|
private java.lang.String |
toolboxKey
|
private org.apache.velocity.app.VelocityEngine |
velocity
|
Fields inherited from class org.apache.velocity.tools.ToolContext |
---|
CATCH_EXCEPTIONS_KEY, CONTEXT_KEY, ENGINE_KEY, LOCALE_KEY, LOG_KEY, PATH_KEY |
Fields inherited from interface org.apache.velocity.tools.view.ViewContext |
---|
APPLICATION, DEFAULT_TOOLBOX_KEY, REQUEST, RESPONSE, SERVLET_CONTEXT_KEY, SESSION |
Constructor Summary | |
---|---|
ViewToolContext(org.apache.velocity.app.VelocityEngine velocity,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.ServletContext application)
|
Method Summary | |
---|---|
protected void |
addToolboxesUnderKey(java.lang.String toolboxKey)
|
boolean |
containsKey(java.lang.String key)
Indicates whether the specified key is in the context. |
java.lang.Object |
get(java.lang.String key)
Looks up and returns the object with the specified key. |
java.lang.Object |
getAttribute(java.lang.String key)
Searches for the named attribute in request, session (if valid), and application scope(s) in order and returns the value associated or null. |
javax.servlet.http.HttpServletRequest |
getRequest()
Returns the current servlet request. |
javax.servlet.http.HttpServletResponse |
getResponse()
Returns the current servlet response. |
protected java.lang.Object |
getServletApi(java.lang.String key)
Returns the current matching servlet request, response, session, or servlet context instance, or null if the key matches none of those keys. |
javax.servlet.ServletContext |
getServletContext()
Returns the servlet context. |
javax.servlet.http.HttpSession |
getSession()
Returns the current session, if any. |
protected java.util.List<Toolbox> |
getToolboxes()
|
protected java.lang.Object |
getToolVar(java.lang.String key)
Finds the automatically provided values, either configured tools or servlet API objects (request, response, etc). |
protected java.lang.Object |
getUserVar(java.lang.String key)
Finds "user" set values, either in the local context or in the scoped attributes if none is in the local context. |
org.apache.velocity.context.Context |
getVelocityContext()
Returns a reference to the Velocity context (this object). |
org.apache.velocity.app.VelocityEngine |
getVelocityEngine()
Returns a reference to the VelocityEngine. |
protected void |
putToolProperties()
|
protected void |
setToolboxKey(java.lang.String key)
|
Methods inherited from class org.apache.velocity.tools.ToolContext |
---|
addToolbox, containsKey, findTool, getKeys, getToolbox, getToolClassMap, getToolProperties, getUserCanOverwriteTools, internalGet, keySet, put, putAll, putToolProperties, putToolProperty, putVelocityEngine, remove, setUserCanOverwriteTools |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final javax.servlet.http.HttpServletRequest request
private final javax.servlet.http.HttpServletResponse response
private final javax.servlet.ServletContext application
private final org.apache.velocity.app.VelocityEngine velocity
private java.lang.String toolboxKey
Constructor Detail |
---|
public ViewToolContext(org.apache.velocity.app.VelocityEngine velocity, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext application)
Method Detail |
---|
protected void setToolboxKey(java.lang.String key)
protected void putToolProperties()
protected java.util.List<Toolbox> getToolboxes()
getToolboxes
in class ToolContext
protected void addToolboxesUnderKey(java.lang.String toolboxKey)
public java.lang.Object get(java.lang.String key)
Looks up and returns the object with the specified key.
See the class documentation for more details.
get
in interface org.apache.velocity.context.Context
get
in class ToolContext
key
- the key of the object requested
ToolContext.setUserCanOverwriteTools(boolean)
,
getUserVar(java.lang.String)
,
getToolVar(java.lang.String)
protected java.lang.Object getUserVar(java.lang.String key)
ToolContext.internalGet(java.lang.String)
,
getAttribute(java.lang.String)
protected java.lang.Object getToolVar(java.lang.String key)
ToolContext.findTool(java.lang.String)
,
getServletApi(java.lang.String)
protected java.lang.Object getServletApi(java.lang.String key)
public java.lang.Object getAttribute(java.lang.String key)
Searches for the named attribute in request, session (if valid), and application scope(s) in order and returns the value associated or null.
getAttribute
in interface ViewContext
public javax.servlet.http.HttpServletRequest getRequest()
Returns the current servlet request.
getRequest
in interface ViewContext
public javax.servlet.http.HttpServletResponse getResponse()
Returns the current servlet response.
getResponse
in interface ViewContext
public javax.servlet.http.HttpSession getSession()
Returns the current session, if any.
public javax.servlet.ServletContext getServletContext()
Returns the servlet context.
getServletContext
in interface ViewContext
public org.apache.velocity.context.Context getVelocityContext()
Returns a reference to the Velocity context (this object).
getVelocityContext
in interface ViewContext
public org.apache.velocity.app.VelocityEngine getVelocityEngine()
Returns a reference to the VelocityEngine.
getVelocityEngine
in interface ViewContext
public boolean containsKey(java.lang.String key)
key
- The key to look for.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |