public class VelocityLayoutServlet extends VelocityViewServlet
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DEFAULT_LAYOUT
The default filename for the servlet's default layout
|
static String |
DEFAULT_ERROR_TEMPLATE
The default error template's filename.
|
static String |
DEFAULT_LAYOUT_DIR
The default layout directory
|
protected String |
defaultLayout |
protected String |
errorTemplate |
static String |
KEY_ERROR_CAUSE
The context key that holds the
Throwable that
broke the rendering of the requested screen. |
static String |
KEY_ERROR_INVOCATION_EXCEPTION
The context key that holds the
MethodInvocationException
that broke the rendering of the requested screen. |
static String |
KEY_ERROR_STACKTRACE
The context key that holds the stack trace of the error that
broke the rendering of the requested screen.
|
static String |
KEY_LAYOUT
The context/parameter key used to specify an alternate
layout to be used for a request instead of the default layout.
|
static String |
KEY_SCREEN_CONTENT
The context key that will hold the content of the screen.
|
protected String |
layoutDir |
static String |
PROPERTY_DEFAULT_LAYOUT
The velocity.properties key for specifying the
servlet's default layout template's filename.
|
static String |
PROPERTY_DYNAMIC_LAYOUT
The velocity.properties key for specifying
whether dynamic layout change is allowed
|
static String |
PROPERTY_ERROR_TEMPLATE
The velocity.properties key for specifying the
servlet's error template.
|
static String |
PROPERTY_LAYOUT_DIR
The velocity.properties key for specifying the
relative directory holding layout templates.
|
BUFFER_OUTPUT_PARAM
Constructor and Description |
---|
VelocityLayoutServlet() |
Modifier and Type | Method and Description |
---|---|
protected void |
error(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Throwable e)
Overrides VelocityViewServlet to display user's custom error template
|
protected void |
fillContext(org.apache.velocity.context.Context ctx,
javax.servlet.http.HttpServletRequest request)
Overrides VelocityViewServlet to check the request for
an alternate layout
|
protected String |
findLayout(javax.servlet.http.HttpServletRequest request)
Searches for a non-default layout to be used for this request.
|
void |
init(javax.servlet.ServletConfig config)
Initializes Velocity, the view servlet and checks for changes to
the initial layout configuration.
|
protected void |
mergeTemplate(org.apache.velocity.Template template,
org.apache.velocity.context.Context context,
javax.servlet.http.HttpServletResponse response)
Overrides VelocityViewServlet.mergeTemplate to do a two-pass
render for handling layouts
|
createContext, doGet, doPost, doRequest, findInitParameter, getLog, getOutputWriter, getTemplate, getTemplate, getVelocityProperty, getVelocityView, handleRequest, initRequest, manageResourceNotFound, mergeTemplate, requestCleanup, setContentType, setVelocityView
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
public static final String PROPERTY_ERROR_TEMPLATE
public static final String PROPERTY_LAYOUT_DIR
public static final String PROPERTY_DEFAULT_LAYOUT
public static final String DEFAULT_ERROR_TEMPLATE
public static final String DEFAULT_LAYOUT_DIR
public static final String DEFAULT_DEFAULT_LAYOUT
public static final String KEY_SCREEN_CONTENT
public static final String KEY_LAYOUT
public static final String KEY_ERROR_CAUSE
Throwable
that
broke the rendering of the requested screen.public static final String KEY_ERROR_STACKTRACE
public static final String KEY_ERROR_INVOCATION_EXCEPTION
MethodInvocationException
that broke the rendering of the requested screen.
If this value is placed in the context, then $error_cause
will hold the error that this invocation exception is wrapping.public static final String PROPERTY_DYNAMIC_LAYOUT
protected String errorTemplate
protected String layoutDir
protected String defaultLayout
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
init
in interface javax.servlet.Servlet
init
in class VelocityViewServlet
config
- servlet configuration parametersjavax.servlet.ServletException
protected void fillContext(org.apache.velocity.context.Context ctx, javax.servlet.http.HttpServletRequest request)
fillContext
in class VelocityViewServlet
ctx
- context for this requestrequest
- client requestprotected String findLayout(javax.servlet.http.HttpServletRequest request)
request
- servlet requestprotected void mergeTemplate(org.apache.velocity.Template template, org.apache.velocity.context.Context context, javax.servlet.http.HttpServletResponse response) throws IOException
mergeTemplate
in class VelocityViewServlet
template
- Template
objectcontext
- Velocity contextresponse
- servlet responseIOException
protected void error(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Throwable e)
error
in class VelocityViewServlet
request
- servlet requestresponse
- servlet responsee
- thrown errorCopyright © 2002–2021 The Apache Software Foundation. All rights reserved.