Package spark

Class TemplateEngine


  • public abstract class TemplateEngine
    extends java.lang.Object
    A Template holds the implementation of the 'render' method. TemplateViewRoute instead of returning the result of calling toString() as body, it returns the result of calling render method. The primary purpose of this kind of Route is provide a way to create generic and reusable components for rendering output using a Template Engine. For example to render objects to html by using Freemarker template engine..
    • Constructor Summary

      Constructors 
      Constructor Description
      TemplateEngine()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      ModelAndView modelAndView​(java.lang.Object model, java.lang.String viewName)
      Creates a new ModelAndView object with given arguments.
      java.lang.String render​(java.lang.Object object)
      Renders the object
      abstract java.lang.String render​(ModelAndView modelAndView)
      Method called to render the output that is sent to client.
      • Methods inherited from class java.lang.Object

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

      • TemplateEngine

        public TemplateEngine()
    • Method Detail

      • render

        public java.lang.String render​(java.lang.Object object)
        Renders the object
        Parameters:
        object - the object
        Returns:
        the rendered model and view
      • modelAndView

        public ModelAndView modelAndView​(java.lang.Object model,
                                         java.lang.String viewName)
        Creates a new ModelAndView object with given arguments.
        Parameters:
        model - object.
        viewName - to be rendered.
        Returns:
        object with model and view set.
      • render

        public abstract java.lang.String render​(ModelAndView modelAndView)
        Method called to render the output that is sent to client.
        Parameters:
        modelAndView - object where object (mostly a POJO) and the name of the view to render are set.
        Returns:
        message that it is sent to client.