|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.velocity.tools.view.VelocityView
public class VelocityView
The class provides the following features:
VelocityView supports the following configuration parameters in web.xml:
There are methods you may wish to override to access, alter or control any part of the request processing chain. Please see the javadocs for more information on :
#setContentType
: #requestCleanup
: #error
:
Field Summary | |
---|---|
static java.lang.String |
CLEAN_CONFIGURATION_KEY
|
static java.lang.String |
CONTENT_TYPE_KEY
The HTTP content type context key. |
static java.lang.String |
CREATE_SESSION_PROPERTY
|
private boolean |
createSession
|
static java.lang.String |
DEFAULT_CONTENT_TYPE
The default content type for the response |
static java.lang.String |
DEFAULT_OUTPUT_ENCODING
Default encoding for the output stream |
static java.lang.String |
DEFAULT_PROPERTIES_PATH
Default Runtime properties. |
static java.lang.String |
DEFAULT_TOOLBOX_KEY
|
private java.lang.String |
defaultContentType
|
static java.lang.String |
DEPRECATED_TOOLS_KEY
Deprecated. |
static java.lang.String |
DEPRECATED_USER_TOOLS_PATH
Deprecated. |
private boolean |
deprecationSupportMode
|
static java.lang.String |
LOAD_DEFAULTS_KEY
|
static java.lang.String |
PROPERTIES_KEY
This is the string that is looked for when getInitParameter is called ("org.apache.velocity.properties"). |
static java.lang.String |
SERVLET_CONTEXT_KEY
Key used to access the ServletContext in the Velocity application attributes. |
private javax.servlet.ServletContext |
servletContext
|
private ToolboxFactory |
toolboxFactory
|
private java.lang.String |
toolboxKey
|
static java.lang.String |
TOOLS_KEY
Key used to access the toolbox configuration file path from the Servlet or webapp init parameters ("org.apache.velocity.tools"). |
static java.lang.String |
USER_PROPERTIES_PATH
Default velocity properties file path. |
static java.lang.String |
USER_TOOLS_PATH
Default toolbox configuration file path. |
private org.apache.velocity.app.VelocityEngine |
velocity
|
private static org.apache.velocity.util.SimplePool |
writerPool
|
Constructor Summary | |
---|---|
VelocityView(javax.servlet.ServletConfig config)
|
|
VelocityView(javax.servlet.ServletConfig config,
java.lang.String toolboxKey)
|
|
VelocityView(javax.servlet.ServletContext context)
|
|
VelocityView(javax.servlet.ServletContext context,
java.lang.String toolboxKey)
|
Method Summary | |
---|---|
protected void |
configure(javax.servlet.ServletConfig config,
ToolboxFactory factory)
|
protected void |
configure(javax.servlet.ServletConfig config,
org.apache.velocity.app.VelocityEngine velocity)
|
protected ViewToolContext |
createContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Creates and returns an initialized Velocity context. |
protected java.lang.String |
findInitParameter(java.lang.String key,
javax.servlet.ServletConfig config)
|
protected FactoryConfiguration |
getConfiguration(java.lang.String path)
|
protected FactoryConfiguration |
getConfiguration(java.lang.String path,
boolean required)
|
org.apache.velocity.context.Context |
getContext(javax.servlet.http.HttpServletRequest request)
|
org.apache.velocity.context.Context |
getContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
java.lang.String |
getDefaultContentType()
|
protected FactoryConfiguration |
getDeprecatedConfig(javax.servlet.ServletConfig config)
Deprecated. |
protected java.io.InputStream |
getInputStream(java.lang.String path,
boolean required)
|
protected org.apache.velocity.runtime.log.Log |
getLog()
|
protected java.lang.Object |
getMutex(javax.servlet.http.HttpSession session)
Returns a mutex (lock object) unique to the specified session to allow for reliable synchronization on the session. |
protected org.apache.commons.collections.ExtendedProperties |
getProperties(java.lang.String path)
|
protected org.apache.commons.collections.ExtendedProperties |
getProperties(java.lang.String path,
boolean required)
|
protected java.lang.String |
getProperty(java.lang.String key,
java.lang.String alternate)
Simplifies process of getting a property from VelocityEngine, because the VelocityEngine interface sucks compared to the singleton's. |
org.apache.velocity.Template |
getTemplate(javax.servlet.http.HttpServletRequest request)
Gets the requested template. |
org.apache.velocity.Template |
getTemplate(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
org.apache.velocity.Template |
getTemplate(java.lang.String name)
Retrieves the requested template. |
org.apache.velocity.Template |
getTemplate(java.lang.String name,
java.lang.String encoding)
Retrieves the requested template with the specified character encoding. |
protected ToolboxFactory |
getToolboxFactory()
|
protected java.lang.String |
getToolboxKey()
|
org.apache.velocity.app.VelocityEngine |
getVelocityEngine()
Returns the underlying VelocityEngine being used. |
protected void |
init(javax.servlet.ServletConfig config)
Initializes ToolboxFactory, VelocityEngine, and sets default encoding for processing requests. |
protected void |
init(javax.servlet.ServletConfig config,
ToolboxFactory factory)
Initializes the ToolboxFactory. |
protected void |
init(javax.servlet.ServletConfig config,
org.apache.velocity.app.VelocityEngine velocity)
Initializes the Velocity runtime, first calling loadConfiguration(ServletConfig) to get a org.apache.commons.collections.ExtendedProperties of configuration information and then calling velocityEngine.init(). |
void |
merge(org.apache.velocity.Template template,
org.apache.velocity.context.Context context,
java.io.Writer writer)
Merges the template with the context. |
protected void |
performMerge(org.apache.velocity.Template template,
org.apache.velocity.context.Context context,
java.io.Writer writer)
This is here so developers may override it and gain access to the Writer which the template will be merged into. |
void |
prepareContext(ViewToolContext context)
|
void |
prepareToolboxes(javax.servlet.http.HttpServletRequest request)
|
org.apache.velocity.context.Context |
render(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
org.apache.velocity.context.Context |
render(javax.servlet.http.HttpServletRequest request,
java.io.Writer out)
|
private boolean |
setConfig(FactoryConfiguration factory,
java.lang.String path,
boolean require)
|
protected void |
setDeprecationSupportMode(boolean support)
|
protected void |
setEncoding(javax.servlet.ServletConfig config)
|
private boolean |
setProps(org.apache.velocity.app.VelocityEngine velocity,
java.lang.String path,
boolean require)
|
private void |
setToolboxKey(java.lang.String toolboxKey)
This method should be private until someone thinks of a good reason to change toolbox keys arbitrarily. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CONTENT_TYPE_KEY
public static final java.lang.String SERVLET_CONTEXT_KEY
public static final java.lang.String DEFAULT_TOOLBOX_KEY
public static final java.lang.String CREATE_SESSION_PROPERTY
public static final java.lang.String DEFAULT_CONTENT_TYPE
public static final java.lang.String DEFAULT_OUTPUT_ENCODING
public static final java.lang.String TOOLS_KEY
@Deprecated public static final java.lang.String DEPRECATED_TOOLS_KEY
public static final java.lang.String USER_TOOLS_PATH
@Deprecated public static final java.lang.String DEPRECATED_USER_TOOLS_PATH
public static final java.lang.String DEFAULT_PROPERTIES_PATH
public static final java.lang.String PROPERTIES_KEY
public static final java.lang.String USER_PROPERTIES_PATH
public static final java.lang.String LOAD_DEFAULTS_KEY
public static final java.lang.String CLEAN_CONFIGURATION_KEY
private static org.apache.velocity.util.SimplePool writerPool
private ToolboxFactory toolboxFactory
private org.apache.velocity.app.VelocityEngine velocity
private javax.servlet.ServletContext servletContext
private java.lang.String defaultContentType
private java.lang.String toolboxKey
private boolean createSession
private boolean deprecationSupportMode
Constructor Detail |
---|
public VelocityView(javax.servlet.ServletConfig config)
public VelocityView(javax.servlet.ServletConfig config, java.lang.String toolboxKey)
public VelocityView(javax.servlet.ServletContext context)
public VelocityView(javax.servlet.ServletContext context, java.lang.String toolboxKey)
Method Detail |
---|
private final void setToolboxKey(java.lang.String toolboxKey)
protected final java.lang.String getToolboxKey()
protected final void setDeprecationSupportMode(boolean support)
public org.apache.velocity.app.VelocityEngine getVelocityEngine()
protected org.apache.velocity.runtime.log.Log getLog()
protected ToolboxFactory getToolboxFactory()
public java.lang.String getDefaultContentType()
protected java.lang.String getProperty(java.lang.String key, java.lang.String alternate)
#initVelocity(ServletConfig,VelocityEngine)
has already been called.
protected void init(javax.servlet.ServletConfig config)
Initializes ToolboxFactory, VelocityEngine, and sets default encoding for processing requests.
NOTE: If no charset is specified in the default.contentType property (in your velocity.properties) and you have specified an output.encoding property, then that will be used as the charset for the default content-type of pages served by this servlet.
config
- servlet configuationprotected void init(javax.servlet.ServletConfig config, org.apache.velocity.app.VelocityEngine velocity)
config
- servlet configuration parametersprotected void init(javax.servlet.ServletConfig config, ToolboxFactory factory)
config
- servlet configuationfactory
- the ToolboxFactory to be initialized for this VelocityViewprotected java.lang.String findInitParameter(java.lang.String key, javax.servlet.ServletConfig config)
protected void configure(javax.servlet.ServletConfig config, org.apache.velocity.app.VelocityEngine velocity)
private boolean setProps(org.apache.velocity.app.VelocityEngine velocity, java.lang.String path, boolean require)
protected void configure(javax.servlet.ServletConfig config, ToolboxFactory factory)
@Deprecated protected FactoryConfiguration getDeprecatedConfig(javax.servlet.ServletConfig config)
private boolean setConfig(FactoryConfiguration factory, java.lang.String path, boolean require)
protected java.io.InputStream getInputStream(java.lang.String path, boolean required)
protected org.apache.commons.collections.ExtendedProperties getProperties(java.lang.String path)
protected org.apache.commons.collections.ExtendedProperties getProperties(java.lang.String path, boolean required)
protected FactoryConfiguration getConfiguration(java.lang.String path)
protected FactoryConfiguration getConfiguration(java.lang.String path, boolean required)
protected void setEncoding(javax.servlet.ServletConfig config)
public org.apache.velocity.context.Context render(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
request
- HttpServletRequest object containing client requestresponse
- HttpServletResponse object for the response
Context
prepared and used to perform the rendering
to allow proper cleanup afterward
java.io.IOException
public org.apache.velocity.context.Context render(javax.servlet.http.HttpServletRequest request, java.io.Writer out) throws java.io.IOException
java.io.IOException
public void prepareToolboxes(javax.servlet.http.HttpServletRequest request)
protected java.lang.Object getMutex(javax.servlet.http.HttpSession session)
protected ViewToolContext createContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Creates and returns an initialized Velocity context.
A new context of classViewToolContext
is created and
initialized.
request
- servlet request from clientresponse
- servlet reponse to clientpublic void prepareContext(ViewToolContext context)
public org.apache.velocity.context.Context getContext(javax.servlet.http.HttpServletRequest request)
public org.apache.velocity.context.Context getContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
public org.apache.velocity.Template getTemplate(javax.servlet.http.HttpServletRequest request)
Gets the requested template.
request
- client request
public org.apache.velocity.Template getTemplate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
public org.apache.velocity.Template getTemplate(java.lang.String name)
name
- The file name of the template to retrieve relative to the
template root.
org.apache.velocity.exception.ResourceNotFoundException
- if template not found
from any available source.
ParseErrorException
- if template cannot be parsed due
to syntax (or other) error.public org.apache.velocity.Template getTemplate(java.lang.String name, java.lang.String encoding)
name
- The file name of the template to retrieve relative to the
template root.encoding
- the character encoding of the template
org.apache.velocity.exception.ResourceNotFoundException
- if template not found
from any available source.
ParseErrorException
- if template cannot be parsed due
to syntax (or other) error.public void merge(org.apache.velocity.Template template, org.apache.velocity.context.Context context, java.io.Writer writer) throws java.io.IOException
template
- template being renderedcontext
- Context created by the createContext(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
writer
- into which the content is rendered
java.io.IOException
protected void performMerge(org.apache.velocity.Template template, org.apache.velocity.context.Context context, java.io.Writer writer) throws java.io.IOException
template
- template object returned by the handleRequest() methodcontext
- Context created by the createContext(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
writer
- a VelocityWriter that the template is merged into
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |