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 Details

    • AbstractFreeMarkerTemplateService

      public AbstractFreeMarkerTemplateService()
  • Method Details

    • setTemplateUpdateDelay

      public void setTemplateUpdateDelay(int nTemplateUpdateDelay)
      Set the template update delay
      Specified by:
      setTemplateUpdateDelay in interface IFreeMarkerTemplateService
      Parameters:
      nTemplateUpdateDelay - the template update delay
    • addPluginMacros

      public void addPluginMacros(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:
      addPluginMacros in interface IFreeMarkerTemplateService
      Parameters:
      strFileName - the filename
    • addPluginAutoInclude

      public void addPluginAutoInclude(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:
      addPluginAutoInclude in interface IFreeMarkerTemplateService
      Parameters:
      strFileName - the filename
    • addPluginAutoImport

      public void addPluginAutoImport(String strNamespace, String strFileName)
      Adds an import file brought by a plugin. This file will be imported for every template (auto-import).
      Specified by:
      addPluginAutoImport in interface IFreeMarkerTemplateService
      Parameters:
      strNamespace - The namespace corresponding to the import file
      strFileName - the filename
    • setSharedVariable

      public void setSharedVariable(String name, Object obj)
      Add a shared variable into every template
      Specified by:
      setSharedVariable in interface IFreeMarkerTemplateService
      Parameters:
      name - name of the shared variable
      obj - value
    • init

      public void init(String strTemplatePath)
      Initializes the service with the templates's path
      Specified by:
      init in interface IFreeMarkerTemplateService
      Parameters:
      strTemplatePath - The template path
    • init

      public void init(String strTemplatePath, jakarta.servlet.ServletContext context)
      Initializes the service with the templates's path and servletContext
      Specified by:
      init in interface IFreeMarkerTemplateService
      Parameters:
      strTemplatePath - The template path
      context - The servlet context
    • init

      public void init(String strTemplatePath, boolean bAcceptIncompatibleImprovements)
      Initializes the service with the templates's path
      Specified by:
      init in interface IFreeMarkerTemplateService
      Parameters:
      strTemplatePath - The template path
      bAcceptIncompatibleImprovements - Use Freemarker new features or stay backward compatible
    • loadTemplate

      public HtmlTemplate loadTemplate(String strPath, String strTemplate)
      Load a template
      Specified by:
      loadTemplate in interface IFreeMarkerTemplateService
      Parameters:
      strPath - the root path
      strTemplate - the path of the template from the root path
      Returns:
      the html template
    • loadTemplate

      public HtmlTemplate loadTemplate(String strPath, String strTemplate, Locale locale, Object rootMap)
      Load a template and process a model
      Specified by:
      loadTemplate in interface IFreeMarkerTemplateService
      Parameters:
      strPath - the root path
      strTemplate - the path of the template from the root path
      locale - The locale
      rootMap - 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:
      loadTemplateFromStringFtl in interface IFreeMarkerTemplateService
      Parameters:
      strTemplateData - The template as a string
      locale - The Locale
      rootMap - 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:
      loadTemplateFromStringFtl in interface IFreeMarkerTemplateService
      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 string
      locale - The Locale
      rootMap - the model root
      bResetCacheTemplate - 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:
      resetConfiguration in interface IFreeMarkerTemplateService
    • resetCache

      public void resetCache()
      Reset the cache
      Specified by:
      resetCache in interface IFreeMarkerTemplateService
    • initConfig

      public void initConfig(Locale locale)
      Init a configuration using the current default path
      Parameters:
      locale - The Locale
    • getAutoIncludes

      public List<String> getAutoIncludes()
      Get the list of auto includes files
      Specified by:
      getAutoIncludes in interface IFreeMarkerTemplateService
      Returns:
      The list or null if no configuration is available
    • addAutoInclude

      public void addAutoInclude(String strFile)
      Add an auto include file
      Specified by:
      addAutoInclude in interface IFreeMarkerTemplateService
      Parameters:
      strFile - The file to add
    • removeAutoInclude

      public void removeAutoInclude(String strFile)
      Remove an auto include file
      Specified by:
      removeAutoInclude in interface IFreeMarkerTemplateService
      Parameters:
      strFile - The file to remove
    • getAutoImports

      public Map<String,String> getAutoImports()
      Get the list of auto imports files
      Specified by:
      getAutoImports in interface IFreeMarkerTemplateService
      Returns:
      The list or null if no configuration is available
    • addAutoImport

      public void addAutoImport(String strNamespace, String strFile)
      Add an auto import file
      Specified by:
      addAutoImport in interface IFreeMarkerTemplateService
      Parameters:
      strNamespace - The namespace corresponding to the import file
      strFile - The file to add
    • removeAutoImport

      public void removeAutoImport(String strNamespace)
      Remove an auto import file
      Specified by:
      removeAutoImport in interface IFreeMarkerTemplateService
      Parameters:
      strNamespace - The namespace corresponding to the import file to remove