de.infoasset.platform.template
Class TemplateFinder

java.lang.Object
  extended by de.infoasset.platform.template.TemplateFinder

public class TemplateFinder
extends java.lang.Object

This class is used to specify the template file to be used by a Templatable. See also TemplateDoc for more informations on the templating system in Toro.

Example

In a typical use case a Templatable wants to specify the file which contains the placeholders by implementing the method Templatable.specifyTemplate(TemplateFinder):
 
 public void specifyTemplate(TemplateFinder templateName) {
     templateName.useStaticName("template");
 }
 
 
In this example a template with the file name template.htm will be used.

Why are things different in Toro?

The easiest way of defining a template would be to specify the template name directly using a string, e.g.,
 Template t = new Template("template.htm");
 
The mechansim used in Toro is more complicated at the first glance because of two things:

How templates are specified and located

In a first step the name of the template is specified using one of the methods useClass(Class), useStaticName(String), or useDynamicName(String, String[]). This results in the name of the template relative to the themes root folder (see ThemesDoc). In the example above this is template. After that the extension .htm is added, if the name has no type extension. In a last step Toro tries to find a template file in the existing theme folders. The order in which the themes are traversed is described in ThemesDoc . In the example the template found might be the file /toro/templates/jakob/template.htm.


Field Summary
static java.lang.String BASE_NAME_STRING
           
static java.lang.String HTM
           
static java.lang.String SET_CONTENT_AREA_STRING
           
static java.lang.String USE_DYNAMIC_NAME_STRING
           
static java.lang.String USE_STATIC_NAME_STRING
           
 
Constructor Summary
TemplateFinder()
           
 
Method Summary
 java.util.List<FileTemplate> getConsistencyTemplates()
           
static java.lang.String getLocatorFromClass(java.lang.Class clazz, boolean stationAllowed)
           
 FileTemplate getTemplate()
           
static java.io.File getThemeDir(java.io.File templatesDir, java.lang.String theme)
           
 void setContentArea(java.lang.String name)
           
 java.lang.String toString()
           
 void useClass(java.lang.Class templateableClass)
          This method uses the given class name to specify the template name similar to what is described in HandlerDispatcher.getHandlerBasedOnConvention(String).
 void useDynamicName(java.lang.String name, java.lang.String[] hints)
          This method is used if the template name only can be infered at runtime.
 void useRequestPlugin()
           
 void useStaticName(java.lang.String name)
          This method specifies the template name using a string literal.
 void useTheme(de.infoasset.toro.assets.InSpace inspace)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HTM

public static final java.lang.String HTM
See Also:
Constant Field Values

BASE_NAME_STRING

public static java.lang.String BASE_NAME_STRING

USE_STATIC_NAME_STRING

public static java.lang.String USE_STATIC_NAME_STRING

USE_DYNAMIC_NAME_STRING

public static java.lang.String USE_DYNAMIC_NAME_STRING

SET_CONTENT_AREA_STRING

public static java.lang.String SET_CONTENT_AREA_STRING
Constructor Detail

TemplateFinder

public TemplateFinder()
Method Detail

useClass

public void useClass(java.lang.Class templateableClass)
This method uses the given class name to specify the template name similar to what is described in HandlerDispatcher.getHandlerBasedOnConvention(String).


useStaticName

public void useStaticName(java.lang.String name)
This method specifies the template name using a string literal.


useDynamicName

public void useDynamicName(java.lang.String name,
                           java.lang.String[] hints)
This method is used if the template name only can be infered at runtime. With the second parameter possible template names can be provided to make consistency checks on these templates (see ConsistencyCheckDoc).


setContentArea

public void setContentArea(java.lang.String name)

getLocatorFromClass

public static java.lang.String getLocatorFromClass(java.lang.Class clazz,
                                                   boolean stationAllowed)

getTemplate

public FileTemplate getTemplate()

getConsistencyTemplates

public java.util.List<FileTemplate> getConsistencyTemplates()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

useRequestPlugin

public void useRequestPlugin()

getThemeDir

public static java.io.File getThemeDir(java.io.File templatesDir,
                                       java.lang.String theme)

useTheme

public void useTheme(de.infoasset.toro.assets.InSpace inspace)