|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.abstracthorizon.danube.velocity.VelocityViewAdapter
public class VelocityViewAdapter
This is implementation of View
that uses Velocity template engine. Model map is used as map of parameters for
Velocity.
This implementation is based on VelocityServlet
| Field Summary | |
|---|---|
static String |
CONTENT_TYPE
The HTTP content type context key. |
protected String |
contentType
The default content type. |
static String |
DEFAULT_CONTENT_TYPE
The default content type for the response |
static String |
DEFAULT_OUTPUT_ENCODING
Default encoding for the output stream |
protected String |
suffix
Template suffix |
protected File |
templatesPath
Path where templates are stored |
protected URL |
templatesURL
Path where templates are stored |
| Constructor Summary | |
|---|---|
VelocityViewAdapter()
Constructor. |
|
| Method Summary | |
|---|---|
protected org.apache.velocity.context.Context |
createContext(Map attributes)
Creates context based on provided model's map |
protected org.apache.velocity.Template |
findTemplate(org.apache.velocity.context.Context ctx,
String view)
This method finds template based on view name and ".vm" file extension. |
String |
getContentType()
Returns default content type |
String |
getSuffix()
Returns template suffix. |
File |
getTemplatesPath()
Returns path where templates are stored |
URL |
getTemplatesURL()
Returns URL where templates are stored |
void |
init()
This metod initialises Velocity engine. |
protected void |
mergeTemplate(org.apache.velocity.Template template,
org.apache.velocity.context.Context context,
HTTPConnection connection)
Generates output from given template |
void |
render(Connection connection,
ModelAndView modelAndView)
This method renders output |
void |
setContentType(String contentType)
Sets default content type |
void |
setSuffix(String suffix)
Sets suffix of templates |
void |
setTemplatesPath(File templatesPath)
Sets path where templates are stored |
void |
setTemplatesURL(URL templatesURL)
Sets URL where templates are stored |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String CONTENT_TYPE
public static final String DEFAULT_CONTENT_TYPE
public static final String DEFAULT_OUTPUT_ENCODING
protected URL templatesURL
protected File templatesPath
protected String suffix
protected String contentType
| Constructor Detail |
|---|
public VelocityViewAdapter()
throws Exception
Exception| Method Detail |
|---|
public void init()
throws InitializationException
Exception
InitializationException
public void render(Connection connection,
ModelAndView modelAndView)
throws ConnectionException
render in interface Viewconnection - http connectionmodelAndView - view name to be used as template's name and model map to be used as attributes
throws ConnectionException
ConnectionException
protected org.apache.velocity.Template findTemplate(org.apache.velocity.context.Context ctx,
String view)
throws Exception
#templatesLocation
ctx - velocity contexttemplateFile -
Exceptionprotected org.apache.velocity.context.Context createContext(Map attributes)
attributes - model's map
protected void mergeTemplate(org.apache.velocity.Template template,
org.apache.velocity.context.Context context,
HTTPConnection connection)
throws Exception
template - templatecontext - velocity contextconnection - http connection result to be rendered to
Exceptionpublic File getTemplatesPath()
public void setTemplatesPath(File templatesPath)
templatesPath - path where templates are stored.public URL getTemplatesURL()
public void setTemplatesURL(URL templatesURL)
templatesURL - URL where templates are stored.public String getContentType()
public void setContentType(String contentType)
contentType - default content typepublic String getSuffix()
public void setSuffix(String suffix)
suffix - suffix of templates
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||