Class AbstractFreeMarkerTemplateService
- java.lang.Object
-
- fr.paris.lutece.portal.service.template.AbstractFreeMarkerTemplateService
-
- All Implemented Interfaces:
IFreeMarkerTemplateService
public abstract class AbstractFreeMarkerTemplateService extends java.lang.Object implements IFreeMarkerTemplateService
Template service based on the Freemarker template engine
-
-
Constructor Summary
Constructors Constructor Description AbstractFreeMarkerTemplateService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAutoImport(java.lang.String strNamespace, java.lang.String strFile)Add an auto import filevoidaddAutoInclude(java.lang.String strFile)Add an auto include filevoidaddPluginAutoImport(java.lang.String strNamespace, java.lang.String strFileName)Adds an import file brought by a plugin.voidaddPluginAutoInclude(java.lang.String strFileName)Adds a macro file (like the main commons.html) brought by a plugin.voidaddPluginMacros(java.lang.String strFileName)Adds a macro file (like the main commons.html) brought by a plugin.java.util.Map<java.lang.String,java.lang.String>getAutoImports()Get the list of auto imports filesjava.util.List<java.lang.String>getAutoIncludes()Get the list of auto includes filesvoidinit(java.lang.String strTemplatePath)Initializes the service with the templates's pathvoidinit(java.lang.String strTemplatePath, boolean bAcceptIncompatibleImprovements)Initializes the service with the templates's pathvoidinitConfig(java.util.Locale locale)Init a configuration using the current default pathHtmlTemplateloadTemplate(java.lang.String strPath, java.lang.String strTemplate)Load a templateHtmlTemplateloadTemplate(java.lang.String strPath, java.lang.String strTemplate, java.util.Locale locale, java.lang.Object rootMap)Load a template and process a modelHtmlTemplateloadTemplateFromStringFtl(java.lang.String strTemplateName, java.lang.String strTemplateData, java.util.Locale locale, java.lang.Object rootMap, boolean bResetCacheTemplate)Load a template from a String and process a model.HtmlTemplateloadTemplateFromStringFtl(java.lang.String strTemplateData, java.util.Locale locale, java.lang.Object rootMap)Load a template from a String and process a model.voidremoveAutoImport(java.lang.String strNamespace)Remove an auto import filevoidremoveAutoInclude(java.lang.String strFile)Remove an auto include filevoidresetCache()Reset the cachevoidresetConfiguration()Clears the configuration cachevoidsetSharedVariable(java.lang.String name, java.lang.Object obj)Add a shared variable into every templatevoidsetTemplateUpdateDelay(int nTemplateUpdateDelay)Set the template update delay-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface fr.paris.lutece.portal.service.template.IFreeMarkerTemplateService
getAbsolutePathFromRelativePath, getDefaultPattern
-
-
-
-
Method Detail
-
setTemplateUpdateDelay
public void setTemplateUpdateDelay(int nTemplateUpdateDelay)
Set the template update delay- Specified by:
setTemplateUpdateDelayin interfaceIFreeMarkerTemplateService- Parameters:
nTemplateUpdateDelay- the template update delay
-
addPluginMacros
public void addPluginMacros(java.lang.String strFileName)
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
public void addPluginAutoInclude(java.lang.String strFileName)
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
public void addPluginAutoImport(java.lang.String strNamespace, java.lang.String strFileName)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
-
setSharedVariable
public void setSharedVariable(java.lang.String name, java.lang.Object obj)Add a shared variable into every template- Specified by:
setSharedVariablein interfaceIFreeMarkerTemplateService- Parameters:
name- name of the shared variableobj- value
-
init
public void init(java.lang.String strTemplatePath)
Initializes the service with the templates's path- Specified by:
initin interfaceIFreeMarkerTemplateService- Parameters:
strTemplatePath- The template path
-
init
public void init(java.lang.String strTemplatePath, boolean bAcceptIncompatibleImprovements)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
public HtmlTemplate loadTemplate(java.lang.String strPath, java.lang.String strTemplate)
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
public HtmlTemplate loadTemplate(java.lang.String strPath, java.lang.String strTemplate, java.util.Locale locale, java.lang.Object rootMap)
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(java.lang.String strTemplateData, java.util.Locale locale, java.lang.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(java.lang.String strTemplateName, java.lang.String strTemplateData, java.util.Locale locale, java.lang.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
public void initConfig(java.util.Locale locale)
Init a configuration using the current default path- Parameters:
locale- The Locale
-
getAutoIncludes
public java.util.List<java.lang.String> getAutoIncludes()
Get the list of auto includes files- Specified by:
getAutoIncludesin interfaceIFreeMarkerTemplateService- Returns:
- The list or null if no configuration is available
-
addAutoInclude
public void addAutoInclude(java.lang.String strFile)
Add an auto include file- Specified by:
addAutoIncludein interfaceIFreeMarkerTemplateService- Parameters:
strFile- The file to add
-
removeAutoInclude
public void removeAutoInclude(java.lang.String strFile)
Remove an auto include file- Specified by:
removeAutoIncludein interfaceIFreeMarkerTemplateService- Parameters:
strFile- The file to remove
-
getAutoImports
public java.util.Map<java.lang.String,java.lang.String> getAutoImports()
Get the list of auto imports files- Specified by:
getAutoImportsin interfaceIFreeMarkerTemplateService- Returns:
- The list or null if no configuration is available
-
addAutoImport
public void addAutoImport(java.lang.String strNamespace, java.lang.String strFile)Add an auto import file- Specified by:
addAutoImportin interfaceIFreeMarkerTemplateService- Parameters:
strNamespace- The namespace corresponding to the import filestrFile- The file to add
-
removeAutoImport
public void removeAutoImport(java.lang.String strNamespace)
Remove an auto import file- Specified by:
removeAutoImportin interfaceIFreeMarkerTemplateService- Parameters:
strNamespace- The namespace corresponding to the import file to remove
-
-