Package spark
Class TemplateViewRouteImpl
java.lang.Object
spark.RouteImpl
spark.TemplateViewRouteImpl
A TemplateViewRoute is built up by a path (for url-matching) and 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..
-
Field Summary
Fields inherited from class spark.RouteImpl
DEFAULT_ACCEPT_TYPE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
TemplateViewRouteImpl
(String path, String acceptType, TemplateViewRoute route) Constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic TemplateViewRouteImpl
create
(String path, String acceptType, TemplateViewRoute route, TemplateEngine engine) factory methodstatic TemplateViewRouteImpl
create
(String path, TemplateViewRoute route, TemplateEngine engine) factory methodmodelAndView
(Object model, String viewName) Creates a new ModelAndView object with given arguments.This method should render the given element into something that can be send through Response element.abstract Object
render
(ModelAndView modelAndView) Method called to render the output that is sent to client.Methods inherited from class spark.RouteImpl
create, create, delegate, getAcceptType, getPath, handle, withPrefix
-
Constructor Details
-
TemplateViewRouteImpl
Constructor- Parameters:
path
- the pathacceptType
- the accept typeroute
-
-
-
Method Details
-
create
public static TemplateViewRouteImpl create(String path, TemplateViewRoute route, TemplateEngine engine) factory method- Parameters:
path
- the pathroute
- the routeengine
- the engine- Returns:
- the wrapper template view route
-
create
public static TemplateViewRouteImpl create(String path, String acceptType, TemplateViewRoute route, TemplateEngine engine) factory method- Parameters:
path
- the pathacceptType
- the accept typeroute
- the routeengine
- the engine- Returns:
- the wrapper template view route
-
render
Description copied from class:RouteImpl
This method should render the given element into something that can be send through Response element. By default this method returns the result of calling toString method in given element, but can be overridden. -
modelAndView
Creates a new ModelAndView object with given arguments.- Parameters:
model
- object.viewName
- t be rendered.- Returns:
- object with model and view set.
-
render
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.
-