org.apache.velocity.tools.view
public class VelocityViewFilter extends java.lang.Object
A filter to ensure VelocityTools Toolbox
es are
available in the request/session/application scopes. This
can simplify the process of integration with other frameworks.
VelocityViewFilter supports the following configuration parameters in web.xml:
true
. If set to false
, then
the default toolbox configuration will not be added to your (if any)
custom configuration. NOTE: The default configuration will also be
suppressed if you are using a deprecated toolbox.xml format and do not
explicitly set this to true
.false
. If set to true
, then
then the final toolbox configuration (the combination of any custom
one(s) provided by yourself and/or the default configuration(s))
will have all invalid tools, properties, and/or data removed prior to
configuring the ToolboxFactory for this servlet by a
ConfigurationCleaner
true
. If set to false
, then
the VelocityView
used by this filter will not be shared
with other VelocityViewFilters, VelocityViewServlet
s or
VelocityViewTag
s in the
application.ViewToolContext
for each request, and then
place it into the request attributes under the key you set. This
is primarily for those who have this filter NOT share a config
(i.e. non-shared VelocityView) and thus will find it easier to
retrieve a working context from the request attributes than it
would be to get the VelocityView for this filter and have it
create the context for them. Most users will have no trouble
getting a shared VelocityView and creating the context themselves.Modifier and Type | Field and Description |
---|---|
private FilterConfig |
config |
static java.lang.String |
CONTEXT_KEY |
private java.lang.String |
contextKey |
private VelocityView |
view |
Constructor and Description |
---|
VelocityViewFilter() |
Modifier and Type | Method and Description |
---|---|
protected Context |
createContext(HttpServletRequest request,
HttpServletResponse response) |
void |
destroy() |
void |
doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
Simply prepares the request (and/or session) toolbox(es)
for other filters, servlets or whatnot to use.
|
protected java.lang.String |
findInitParameter(java.lang.String key)
Looks up an init parameter with the specified key in either the
FilterConfig or, failing that, in the ServletContext.
|
protected java.lang.String |
getContextKey() |
protected FilterConfig |
getFilterConfig() |
protected VelocityView |
getVelocityView() |
void |
init(FilterConfig config)
Initializes VelocityView used to process requests.
|
public static final java.lang.String CONTEXT_KEY
private VelocityView view
private FilterConfig config
private java.lang.String contextKey
public void init(FilterConfig config) throws ServletException
Initializes VelocityView used to process requests. Called by the servlet container on loading.
config
- filter configuationServletException
protected FilterConfig getFilterConfig()
protected VelocityView getVelocityView()
protected java.lang.String getContextKey()
protected java.lang.String findInitParameter(java.lang.String key)
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws java.io.IOException, ServletException
ViewToolContext
and put
it in the request attributes under that key.java.io.IOException
ServletException
protected Context createContext(HttpServletRequest request, HttpServletResponse response)
public void destroy()
Copyright (c) 2003-2007 Apache Software Foundation