org.abstracthorizon.danube.freemarker
Class FreeMarkerViewAdapter

java.lang.Object
  extended by org.abstracthorizon.danube.freemarker.FreeMarkerViewAdapter
All Implemented Interfaces:
View

public class FreeMarkerViewAdapter
extends Object
implements View

This is implementation of View that uses Velocity template engine. Model map is used as map of parameters for Velocity.

Author:
Daniel Sendula

Nested Class Summary
 class FreeMarkerViewAdapter.LocalTemplateLoader
          Local template loader that uses templates path or templates URL (which ever is supplied).
 
Field Summary
protected  Configuration configuration
          Configuration
static String DEFAULT_SUFFIX
          Default pages suffix is ".page"
protected  org.slf4j.Logger logger
          Logger
protected  String suffix
          Suffix to be used for templates
protected  File templatesPath
          Path where templates are stored
protected  URL templatesURL
          URL where templates are stored
 
Constructor Summary
FreeMarkerViewAdapter()
          Constructor.
 
Method Summary
protected  TemplateLoader createTemplateLoader()
           
 String getSuffix()
          Returns suffix of the templates
 File getTemplatesPath()
          Returns path where templates are stored
 URL getTemplatesURL()
          Returns URL where templaes are to be read from
 void init()
          This metod initialises Velocity engine.
protected  String makeTemplateName(String view)
          Creates name of the template
 void render(Connection connection, ModelAndView modelAndView)
          This method renders output
 void setSuffix(String suffix)
          Sets suffix of the templates
 void setTemplatesPath(File templatesPath)
          Sets path where templates are stored.
 void setTemplatesURL(URL templatesURL)
          Sets URL templates are to be read from.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected org.slf4j.Logger logger
Logger


DEFAULT_SUFFIX

public static final String DEFAULT_SUFFIX
Default pages suffix is ".page"

See Also:
Constant Field Values

templatesPath

protected File templatesPath
Path where templates are stored


templatesURL

protected URL templatesURL
URL where templates are stored


suffix

protected String suffix
Suffix to be used for templates


configuration

protected Configuration configuration
Configuration

Constructor Detail

FreeMarkerViewAdapter

public FreeMarkerViewAdapter()
Constructor.

Method Detail

init

public void init()
          throws RuntimeIOException
This metod initialises Velocity engine.

Throws:
RuntimeIOException

createTemplateLoader

protected TemplateLoader createTemplateLoader()
                                       throws RuntimeIOException
Throws:
RuntimeIOException

render

public void render(Connection connection,
                   ModelAndView modelAndView)
            throws ConnectionException
This method renders output

Specified by:
render in interface View
Parameters:
connection - http connection
modelAndView - view name to be used as template's name and model map to be used as attributes
Throws:
ConnectionException

getTemplatesPath

public File getTemplatesPath()
Returns path where templates are stored

Returns:
Returns the templatePath.

setTemplatesPath

public void setTemplatesPath(File templatesPath)
Sets path where templates are stored. Note: only a file or URL need to be set, not both.

Parameters:
templatesPath - path where templates are stored.

getTemplatesURL

public URL getTemplatesURL()
Returns URL where templaes are to be read from

Returns:
URL where templaes are to be read from

setTemplatesURL

public void setTemplatesURL(URL templatesURL)
Sets URL templates are to be read from. Note: only a file or URL need to be set, not both.

Parameters:
templatesURL - URL templates are to be read from

makeTemplateName

protected String makeTemplateName(String view)
Creates name of the template

Parameters:
view - name of the view
Returns:
returns template's name

getSuffix

public String getSuffix()
Returns suffix of the templates

Returns:
suffix

setSuffix

public void setSuffix(String suffix)
Sets suffix of the templates

Parameters:
suffix - suffix


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.