|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.view.AbstractView
org.springframework.web.servlet.view.xslt.AbstractXsltView
Convenient superclass for views rendered using an XSLT stylesheet. Subclasses must provide the XML W3C document to transform. They do not need to concern themselves with XSLT.
Properties:
Setting cache to false will cause the templates object to be reloaded for each rendering. This is useful during development, but will seriously affect performance in production and isn't threadsafe.
| Field Summary | |
static java.lang.String |
DEFAULT_ROOT
|
| Fields inherited from class org.springframework.web.servlet.view.AbstractView |
DEFAULT_CONTENT_TYPE |
| Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
logger |
| Constructor Summary | |
AbstractXsltView()
|
|
| Method Summary | |
protected abstract org.w3c.dom.Node |
createDomNode(java.util.Map model,
java.lang.String root,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Return the XML node to transform. |
protected void |
doTransform(java.util.Map model,
org.w3c.dom.Node dom,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Perform the actual transformation, writing to the HTTP response. |
protected void |
doTransform(org.w3c.dom.Node dom,
java.util.Map parameters,
javax.xml.transform.Result result,
java.lang.String encoding)
Perform the actual transformation, writing to the given result. |
protected java.util.Map |
getParameters()
Return a Map of parameters to be applied to the stylesheet. |
protected java.util.Map |
getParameters(javax.servlet.http.HttpServletRequest request)
Return a Map of parameters to be applied to the stylesheet. |
protected javax.xml.transform.Source |
getStylesheetSource(Resource stylesheetLocation)
Load the stylesheet. |
protected void |
initApplicationContext()
Here we load our template, as we need the ApplicationContext to do it. |
protected void |
renderMergedOutputModel(java.util.Map model,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Subclasses must implement this method to actually render the view. |
void |
setCache(boolean cache)
Set whether to activate the cache. |
void |
setRoot(java.lang.String root)
Document root element name. |
void |
setStylesheetLocation(Resource stylesheetLocation)
Set the location of the XSLT stylesheet. |
void |
setUriResolver(javax.xml.transform.URIResolver uriResolver)
Set the URIResolver used in the transform. |
| Methods inherited from class org.springframework.web.servlet.view.AbstractView |
addStaticAttribute, createRequestContext, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getStaticAttributes, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setRequestContextAttribute |
| Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport |
getServletContext, getTempDir, getWebApplicationContext |
| Methods inherited from class org.springframework.context.support.ApplicationObjectSupport |
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext |
| 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 DEFAULT_ROOT
| Constructor Detail |
public AbstractXsltView()
| Method Detail |
public void setStylesheetLocation(Resource stylesheetLocation)
stylesheetLocation - the location of the XSLT stylesheetResourceLoader.getResource(java.lang.String)public void setRoot(java.lang.String root)
root - document root element nameDEFAULT_ROOTpublic void setUriResolver(javax.xml.transform.URIResolver uriResolver)
uriResolver - URIResolver to set. No URIResolver
will be set if this is null (this is the default).public void setCache(boolean cache)
protected final void initApplicationContext()
throws ApplicationContextException
initApplicationContext in class ApplicationObjectSupportApplicationContextException - in case of initialization errors
protected javax.xml.transform.Source getStylesheetSource(Resource stylesheetLocation)
throws ApplicationContextException
ApplicationContextException
protected final void renderMergedOutputModel(java.util.Map model,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.lang.Exception
AbstractViewThe first step will be preparing the request: In the JSP case, this would mean setting model objects as request attributes. The second step will be the actual rendering of the view, for example including the JSP via a RequestDispatcher.
renderMergedOutputModel in class AbstractViewmodel - combined output Map, with dynamic values taking precedence
over static attributesrequest - current HTTP requestresponse - current HTTP response
java.lang.Exception - if rendering failed
protected abstract org.w3c.dom.Node createDomNode(java.util.Map model,
java.lang.String root,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.lang.Exception
model - the model Maproot - name for root element. This can be supplied as a bean property
to concrete subclasses within the view definition file, but will be overridden
in the case of a single object in the model map to be the key for that object.
If no root property is specified and multiple model objects exist, a default
root tag name will be supplied.request - HTTP request. Subclasses won't normally use this, as
request processing should have been complete. However, we might to
create a RequestContext to expose as part of the model.response - HTTP response. Subclasses won't normally use this,
however there may sometimes be a need to set cookies.
java.lang.Exception - we let this method throw any exception; the
AbstractXlstView superclass will catch exceptions
protected void doTransform(java.util.Map model,
org.w3c.dom.Node dom,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.lang.Exception
Default implementation delegates to the doTransform version that takes a Result argument, building a StreamResult for the ServletResponse OutputStream.
model - the model Mapdom - the XNL node to transformrequest - current HTTP requestresponse - current HTTP response
java.lang.Exception - we let this method throw any exception; the
AbstractXlstView superclass will catch exceptionsdoTransform(Node, Map, Result, String),
StreamResult,
ServletResponse.getOutputStream()
protected void doTransform(org.w3c.dom.Node dom,
java.util.Map parameters,
javax.xml.transform.Result result,
java.lang.String encoding)
throws java.lang.Exception
dom - the XML node to transformparameters - a Map of parameters to be applied to the stylesheetresult - the result to write to
java.lang.Exception - we let this method throw any exception; the
AbstractXlstView superclass will catch exceptionsprotected java.util.Map getParameters(javax.servlet.http.HttpServletRequest request)
Default implementation delegates to simple getParameter version.
request - current HTTP request
getParameters(),
Transformer.setParameter(java.lang.String, java.lang.Object)protected java.util.Map getParameters()
Default implementation delegates simply returns null.
getParameters(HttpServletRequest),
Transformer.setParameter(java.lang.String, java.lang.Object)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||