Class FreeMarkerProcessor

  • All Implemented Interfaces:
    org.alfresco.processor.Processor, TemplateProcessor, TemplateValueConverter

    public class FreeMarkerProcessor
    extends BaseProcessor
    implements TemplateProcessor, TemplateValueConverter
    FreeMarker implementation of the template processor interface.

    Service to process FreeMarker template files loaded from various sources including the classpath, repository and directly from a String.

    The template is processed against a data model generally consisting of a map of named objects. FreeMarker can natively handle any POJO objects using standard bean notation syntax. It has support for walking List objects. A 'standard' data model helper is provided to help generate an object model containing well known objects such as the Company Home, User Home and current User nodes. It also provides helpful util classes to process Date objects and repository specific custom methods.

    Author:
    Kevin Roast
    • Constructor Detail

      • FreeMarkerProcessor

        public FreeMarkerProcessor()
    • Method Detail

      • setDefaultEncoding

        public void setDefaultEncoding​(java.lang.String defaultEncoding)
        Set the default template encoding
        Parameters:
        defaultEncoding - the default encoding
      • setLocalizedLookup

        public void setLocalizedLookup​(boolean localizedLookup)
        Enable or disable Freemarker's localized lookup feature
      • getConfig

        protected freemarker.template.Configuration getConfig()
        Get the FreeMarker configuration for this instance
        Returns:
        FreeMarker configuration
      • getStringConfig

        protected freemarker.template.Configuration getStringConfig​(java.lang.String path,
                                                                    java.lang.String template)
        FreeMarker configuration for loading the specified template directly from a String
        Parameters:
        path - Pseudo Path to the template
        template - Template content
        Returns:
        FreeMarker configuration
      • convertValue

        public java.lang.Object convertValue​(java.lang.Object value,
                                             TemplateImageResolver imageResolver)
        Description copied from interface: TemplateValueConverter
        Converts a Java object (e.g. one produced by a method call) to one suitable for use within a template.
        Specified by:
        convertValue in interface TemplateValueConverter
        Parameters:
        value - the Java object to convert
        imageResolver - the image resolver
        Returns:
        the converted object