|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.webwork.components.Component
com.opensymphony.webwork.views.sitemesh.ApplyDecoratorBean
public class ApplyDecoratorBean
This is the WebWork component that implements Freemarker's ApplyDecorator Transform. To use this Freemarker Transform, it needs to be enabled in webwork.properties (which is enabled by default)
webwork.freemarker.sitemesh.applyDecoratorTransform = trueAn example of usage would be as follows:- In Sitemesh's decorators.xml
<decorators defaultdir="/WEB-INF/decorators"> .... <decorator name="panel" page="/panelDecorator.ftl" /> </decorators*gt;Decorator (panelDecorator.ftl)
<table border="1"> <tr> <td>${title}</td> </tr> <tr> <td>${body}</td> </tr> </table>Freemarker page that uses decorator
<html> <head> <title>some title</title> </head> <body> <h1>some body title</h1> <@sitemesh.applydecorator name="panel" page="/pages/pageToBeDecorated.ftl" /> </body> </html>An example of pageToBeDecorated.ftl
<html> <head> <title>Panel Title</title> </head> <body> Panel Content </body> </html>The nett outcome would be:-
<html> <title>some title&l/title> <body> <h1>some body title</h1> <table border="1"> <tr> <td>Panel Title</td> </tr> <tr> <td>Panel Content</td> </tr> </table> </body> </html>The following are method hooks available to ApplyDecoratorBean and its subclass
SitemeshModel
,
FreemarkerManager.buildTemplateModel(OgnlValueStack, Object,
ServletContext, HttpServletRequest, HttpServletResponse, ObjectWrapper)
Field Summary |
---|
Fields inherited from class com.opensymphony.webwork.components.Component |
---|
COMPONENT_STACK, id, parameters, stack |
Constructor Summary | |
---|---|
ApplyDecoratorBean(OgnlValueStack stack,
HttpServletRequest request,
HttpServletResponse response)
|
Method Summary | |
---|---|
protected freemarker.template.SimpleHash |
createModel()
Create a Freemarker's Model through FreemarkerManager.buildTemplateModel(OgnlValueStack, Object, ServletContext, HttpServletRequest, HttpServletResponse, ObjectWrapper) . |
protected Locale |
deduceLocale(ActionInvocation invocation,
freemarker.template.Configuration configuration)
Attempt to deduce the Locale, based on invocation and
Freemarker's configuration . |
protected boolean |
end(Writer writer,
String body,
boolean popComponentStack)
Callback for the start tag of this component. |
protected void |
endAllowingExceptionThrowing(Writer writer,
String body)
Render the page specified with the |
String |
getContentType()
The content type, default to "text/html". |
protected com.opensymphony.module.sitemesh.Decorator |
getDecorator(HttpServletRequest request,
String decoratorName)
Returns a Sitemesh Decorator object with the decoratorName specified. |
String |
getEncoding()
Set the encoding eg. |
protected freemarker.template.Template |
getFreemarkerTemplate(String templatePath)
Method Hook: Returns a Freemarker's Template bsaed on the templatePath
supplied. |
String |
getName()
Set the name of the Sitemesh decorator to be used. |
String |
getPage()
Set the page to be decorated. |
protected com.opensymphony.module.sitemesh.PageParser |
getPageParser(String contentType)
Returns a Sitemesh PageParser object with the contentType
specified, which by default is "text/html". |
protected com.opensymphony.module.sitemesh.Factory |
getSitemeshFactory()
Returns a Sitemesh Factory object. |
protected com.opensymphony.module.sitemesh.Page |
parsePageObjectFromAbsoluteUrl(String absoluteUrl)
Returns back a Sitemesh Page object assuming that the absoluteUrl is
the content of the "to-be-decorated" page. |
protected com.opensymphony.module.sitemesh.Page |
parsePageObjectFromContent(String content)
Returns back a Sitemesh Page object assuming that the content is
the content of the "to-be-decorated" page. |
protected com.opensymphony.module.sitemesh.Page |
parsePageObjectFromRelativeUrlPath(String relativeUrl)
Returns a Sitemesh Page object assuming the relativeUrl is
the freemarker page that is "to-be-decorated". |
void |
setContentType(String contentType)
|
void |
setEncoding(String encoding)
|
void |
setName(String name)
|
void |
setPage(String page)
|
boolean |
start(Writer writer)
Callback for the start tag of this component. |
Methods inherited from class com.opensymphony.webwork.components.Component |
---|
addAllParameters, addParameter, altSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getId, getParameters, getStack, popComponentStack, setId, toString, usesBody |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ApplyDecoratorBean(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response)
stack
- Method Detail |
---|
public String getName()
public void setName(String name)
public String getPage()
public void setPage(String page)
public String getContentType()
public void setContentType(String contentType)
public String getEncoding()
public void setEncoding(String encoding)
public boolean start(Writer writer)
Component
start
in class Component
writer
- the output writer.
Component.start(java.io.Writer)
protected boolean end(Writer writer, String body, boolean popComponentStack)
Component
end
in class Component
writer
- the output writer.body
- the rendered body.popComponentStack
- should the component stack be popped?
Component.end(java.io.Writer, java.lang.String, boolean)
protected void endAllowingExceptionThrowing(Writer writer, String body) throws IOException, ServletException, freemarker.template.TemplateException
page specified with the decorator
- Parameters:
writer
- body
-
- Throws:
IOException
ServletException
freemarker.template.TemplateException
protected freemarker.template.Template getFreemarkerTemplate(String templatePath) throws IOException, freemarker.template.TemplateException
templatePath
supplied.
templatePath
-
IOException
freemarker.template.TemplateException
protected com.opensymphony.module.sitemesh.Page parsePageObjectFromContent(String content) throws IOException
content
is
the content of the "to-be-decorated" page.
content
-
IOException
protected com.opensymphony.module.sitemesh.Page parsePageObjectFromAbsoluteUrl(String absoluteUrl) throws IOException
absoluteUrl
is
the content of the "to-be-decorated" page.
absoluteUrl
-
IOException
protected com.opensymphony.module.sitemesh.Page parsePageObjectFromRelativeUrlPath(String relativeUrl) throws freemarker.template.TemplateException, IOException
relativeUrl
is
the freemarker page that is "to-be-decorated".
relativeUrl
-
freemarker.template.TemplateException
IOException
protected com.opensymphony.module.sitemesh.Factory getSitemeshFactory()
protected com.opensymphony.module.sitemesh.PageParser getPageParser(String contentType)
contentType
specified, which by default is "text/html".
contentType
-
protected com.opensymphony.module.sitemesh.Decorator getDecorator(HttpServletRequest request, String decoratorName)
decoratorName
specified.
request
- decoratorName
-
protected Locale deduceLocale(ActionInvocation invocation, freemarker.template.Configuration configuration)
invocation
and
Freemarker's configuration
.
invocation
- configuration
-
protected freemarker.template.SimpleHash createModel() throws freemarker.template.TemplateException
FreemarkerManager.buildTemplateModel(OgnlValueStack, Object, ServletContext, HttpServletRequest, HttpServletResponse, ObjectWrapper)
.
freemarker.template.TemplateException
|
WebWork Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |