Class AbstractFreeMarkerTemplateService
java.lang.Object
fr.paris.lutece.portal.service.template.AbstractFreeMarkerTemplateService
- All Implemented Interfaces:
IFreeMarkerTemplateService
public abstract class AbstractFreeMarkerTemplateService
extends Object
implements IFreeMarkerTemplateService
Template service based on the Freemarker template engine
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAutoImport(String strNamespace, String strFile) Add an auto import filevoidaddAutoInclude(String strFile) Add an auto include filevoidaddPluginAutoImport(String strNamespace, String strFileName) Adds an import file brought by a plugin.voidaddPluginAutoInclude(String strFileName) Adds a macro file (like the main commons.html) brought by a plugin.voidaddPluginMacros(String strFileName) Adds a macro file (like the main commons.html) brought by a plugin.Get the list of auto imports filesGet the list of auto includes filesvoidInitializes the service with the templates's pathvoidInitializes the service with the templates's pathvoidinitConfig(Locale locale) Init a configuration using the current default pathloadTemplate(String strPath, String strTemplate) Load a templateloadTemplate(String strPath, String strTemplate, Locale locale, Object rootMap) Load a template and process a modelloadTemplateFromStringFtl(String strTemplateName, String strTemplateData, Locale locale, Object rootMap, boolean bResetCacheTemplate) Load a template from a String and process a model.loadTemplateFromStringFtl(String strTemplateData, Locale locale, Object rootMap) Load a template from a String and process a model.voidremoveAutoImport(String strNamespace) Remove an auto import filevoidremoveAutoInclude(String strFile) Remove an auto include filevoidReset the cachevoidClears the configuration cachevoidsetSharedVariable(String name, Object obj) Add a shared variable into every templatevoidsetTemplateAutoEscape(boolean bTemplateAutoEscape) Set the template autoescapingvoidsetTemplateUpdateDelay(int nTemplateUpdateDelay) Set the template update delayMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface fr.paris.lutece.portal.service.template.IFreeMarkerTemplateService
getAbsolutePathFromRelativePath, getDefaultPattern
-
Constructor Details
-
AbstractFreeMarkerTemplateService
public AbstractFreeMarkerTemplateService()
-
-
Method Details
-
setTemplateUpdateDelay
public void setTemplateUpdateDelay(int nTemplateUpdateDelay) Set the template update delay- Specified by:
setTemplateUpdateDelayin interfaceIFreeMarkerTemplateService- Parameters:
nTemplateUpdateDelay- the template update delay
-
setTemplateAutoEscape
public void setTemplateAutoEscape(boolean bTemplateAutoEscape) Set the template autoescaping- Specified by:
setTemplateAutoEscapein interfaceIFreeMarkerTemplateService- Parameters:
bTemplateAutoEscape- true to enable autoescaping
-
addPluginMacros
Adds a macro file (like the main commons.html) brought by a plugin. This file will be included for every template (autoinclude).- Specified by:
addPluginMacrosin interfaceIFreeMarkerTemplateService- Parameters:
strFileName- the filename
-
addPluginAutoInclude
Adds a macro file (like the main commons.html) brought by a plugin. This file will be included for every template (auto-include).- Specified by:
addPluginAutoIncludein interfaceIFreeMarkerTemplateService- Parameters:
strFileName- the filename
-
addPluginAutoImport
Adds an import file brought by a plugin. This file will be imported for every template (auto-import).- Specified by:
addPluginAutoImportin interfaceIFreeMarkerTemplateService- Parameters:
strNamespace- The namespace corresponding to the import filestrFileName- the filename
-
init
Initializes the service with the templates's path- Specified by:
initin interfaceIFreeMarkerTemplateService- Parameters:
strTemplatePath- The template path
-
init
Initializes the service with the templates's path- Specified by:
initin interfaceIFreeMarkerTemplateService- Parameters:
strTemplatePath- The template pathbAcceptIncompatibleImprovements- Use Freemarker new features or stay backward compatible
-
loadTemplate
Load a template- Specified by:
loadTemplatein interfaceIFreeMarkerTemplateService- Parameters:
strPath- the root pathstrTemplate- the path of the template from the root path- Returns:
- the html template
-
loadTemplate
Load a template and process a model- Specified by:
loadTemplatein interfaceIFreeMarkerTemplateService- Parameters:
strPath- the root pathstrTemplate- the path of the template from the root pathlocale- The localerootMap- the model root- Returns:
- the processed html template
-
loadTemplateFromStringFtl
public HtmlTemplate loadTemplateFromStringFtl(String strTemplateData, Locale locale, Object rootMap) Load a template from a String and process a model. the template data is stored in the StringTemplateLoader of freemarker. the template key is generate by a hash of the template data.- Specified by:
loadTemplateFromStringFtlin interfaceIFreeMarkerTemplateService- Parameters:
strTemplateData- The template as a stringlocale- TheLocalerootMap- the model root- Returns:
- the processed html template
-
loadTemplateFromStringFtl
public HtmlTemplate loadTemplateFromStringFtl(String strTemplateName, String strTemplateData, Locale locale, Object rootMap, boolean bResetCacheTemplate) Load a template from a String and process a model. the template data is stored in the StringTemplateLoader of freemarker using strTemplateName as key- Specified by:
loadTemplateFromStringFtlin interfaceIFreeMarkerTemplateService- Parameters:
strTemplateName- the key of the template put in the StringTemplateLoader. The template name must be a Fully qualified name (skin.plugins.myplugin.manage_my_objects)strTemplateData- The template as a stringlocale- TheLocalerootMap- the model rootbResetCacheTemplate- force the update of the template data stored in the StringTemplateLoader- Returns:
- the processed html template
-
resetConfiguration
public void resetConfiguration()Clears the configuration cache- Specified by:
resetConfigurationin interfaceIFreeMarkerTemplateService
-
resetCache
public void resetCache()Reset the cache- Specified by:
resetCachein interfaceIFreeMarkerTemplateService
-
initConfig
Init a configuration using the current default path- Parameters:
locale- The Locale
-
getAutoIncludes
Get the list of auto includes files- Specified by:
getAutoIncludesin interfaceIFreeMarkerTemplateService- Returns:
- The list or null if no configuration is available
-
addAutoInclude
Add an auto include file- Specified by:
addAutoIncludein interfaceIFreeMarkerTemplateService- Parameters:
strFile- The file to add
-
removeAutoInclude
Remove an auto include file- Specified by:
removeAutoIncludein interfaceIFreeMarkerTemplateService- Parameters:
strFile- The file to remove
-
getAutoImports
Get the list of auto imports files- Specified by:
getAutoImportsin interfaceIFreeMarkerTemplateService- Returns:
- The list or null if no configuration is available
-
addAutoImport
Add an auto import file- Specified by:
addAutoImportin interfaceIFreeMarkerTemplateService- Parameters:
strNamespace- The namespace corresponding to the import filestrFile- The file to add
-
removeAutoImport
Remove an auto import file- Specified by:
removeAutoImportin interfaceIFreeMarkerTemplateService- Parameters:
strNamespace- The namespace corresponding to the import file to remove
-