Class FreemarkerViewDriver

java.lang.Object
com.blackrook.small.views.freemarker.FreemarkerViewDriver
All Implemented Interfaces:
com.blackrook.small.roles.ViewDriver

public abstract class FreemarkerViewDriver extends Object implements com.blackrook.small.roles.ViewDriver
The Freemarker View Driver for Small.
Author:
Matthew Tropiano
  • Constructor Summary

    Constructors
    Constructor
    Description
    FreemarkerViewDriver(freemarker.cache.TemplateLoader loader)
    Creates the Freemarker View Driver for Small with a specific template loader.
    FreemarkerViewDriver(freemarker.template.Configuration configuration)
    Creates the Freemarker View Driver for Small.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract boolean
    Checks if this handler should process a view by its view name.
    static freemarker.cache.TemplateLoader
    Creates a new file-based template loader.
    static freemarker.cache.TemplateLoader
    Creates a new file-based template loader.
    static freemarker.cache.TemplateLoader
    Creates a new resource-based template loader.
    boolean
    handleView(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object model, String viewName)
     
    void
    setCapacity(int capacity)
    Deprecated.
    Since 1.0.1, this has no effect.
    void
    setMimeType(String mimeType)
    Sets the forced MIME-Type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FreemarkerViewDriver

      public FreemarkerViewDriver(freemarker.template.Configuration configuration)
      Creates the Freemarker View Driver for Small.
      Parameters:
      configuration - the Freemarker Configuration.
    • FreemarkerViewDriver

      public FreemarkerViewDriver(freemarker.cache.TemplateLoader loader)
      Creates the Freemarker View Driver for Small with a specific template loader. Also turns off "localized lookup" - assumes asked-for view is the actual name.
      Parameters:
      loader - the template loader to use.
  • Method Details

    • setMimeType

      public void setMimeType(String mimeType)
      Sets the forced MIME-Type.
      Parameters:
      mimeType - the forced MIME-type for the output.
    • setCapacity

      @Deprecated public void setCapacity(int capacity)
      Deprecated.
      Since 1.0.1, this has no effect.
      Sets the initial capacity of the output buffer for the view.
      Parameters:
      capacity - the new initial capacity for the output buffer.
      Throws:
      IllegalArgumentException - if capacity is < 1.
    • createResourceTemplateLoader

      public static freemarker.cache.TemplateLoader createResourceTemplateLoader(String resourceRoot)
      Creates a new resource-based template loader.
      Parameters:
      resourceRoot - the root path for resources.
      Returns:
      the created template loader.
    • createFileTemplateLoader

      public static freemarker.cache.TemplateLoader createFileTemplateLoader(String fileRootPath)
      Creates a new file-based template loader.
      Parameters:
      fileRootPath - the root path for files.
      Returns:
      the created template loader.
      Throws:
      IllegalArgumentException - if fileRootPath is not a directory.
    • createFileTemplateLoader

      public static freemarker.cache.TemplateLoader createFileTemplateLoader(File fileRoot)
      Creates a new file-based template loader.
      Parameters:
      fileRoot - the root path for files.
      Returns:
      the created template loader.
      Throws:
      IllegalArgumentException - if fileRoot is not a directory.
    • acceptViewName

      protected abstract boolean acceptViewName(String viewName)
      Checks if this handler should process a view by its view name. If false is returned, this view driver is skipped.
      Parameters:
      viewName - the name of the view to process.
      Returns:
      true if so, false if not.
    • handleView

      public boolean handleView(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object model, String viewName) throws com.blackrook.small.exception.views.ViewProcessingException
      Specified by:
      handleView in interface com.blackrook.small.roles.ViewDriver
      Throws:
      com.blackrook.small.exception.views.ViewProcessingException