Class ModelAndMustacheView
- java.lang.Object
-
- org.springframework.web.servlet.ModelAndView
-
- com.github.mjeanroy.springmvc.view.mustache.core.ModelAndMustacheView
-
public class ModelAndMustacheView extends org.springframework.web.servlet.ModelAndView
Extension ofModelAndView
class that provide shortcuts to get and add partial mappings that will be used to render view.
-
-
Constructor Summary
Constructors Constructor Description ModelAndMustacheView()
Default constructor for bean-style usage: populating bean properties instead of passing in constructor arguments.ModelAndMustacheView(MustacheView view)
Convenient constructor when there is no model data to expose.ModelAndMustacheView(MustacheView view, String modelName, Object modelObject)
Convenient constructor to take a single model object.ModelAndMustacheView(MustacheView view, Map<String,?> model)
Creates new ModelAndView given a View object and a model.ModelAndMustacheView(String viewName)
Convenient constructor when there is no model data to expose.ModelAndMustacheView(String viewName, String modelName, Object modelObject)
Convenient constructor to take a single model object.ModelAndMustacheView(String viewName, Map<String,?> model)
Creates new ModelAndView given a view name and a model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPartial(String key, String name)
Add new partials mapping to the view.void
addPartials(Map<String,String> partials)
Add new partials mapping to the view.Map<String,String>
getPartials()
Get current partials stored in view.
-
-
-
Constructor Detail
-
ModelAndMustacheView
public ModelAndMustacheView()
Default constructor for bean-style usage: populating bean properties instead of passing in constructor arguments.- See Also:
ModelAndView.setView(org.springframework.web.servlet.View)
,ModelAndView.setViewName(String)
-
ModelAndMustacheView
public ModelAndMustacheView(String viewName)
Convenient constructor when there is no model data to expose. Can also be used in conjunction withaddObject
.- Parameters:
viewName
- name of the View to render, to be resolved by the DispatcherServlet's ViewResolver- See Also:
ModelAndView.addObject(java.lang.String, java.lang.Object)
-
ModelAndMustacheView
public ModelAndMustacheView(MustacheView view)
Convenient constructor when there is no model data to expose. Can also be used in conjunction withaddObject
.- Parameters:
view
- View object to render- See Also:
ModelAndView.addObject(java.lang.String, java.lang.Object)
-
ModelAndMustacheView
public ModelAndMustacheView(String viewName, Map<String,?> model)
Creates new ModelAndView given a view name and a model.- Parameters:
viewName
- name of the View to render, to be resolved by the DispatcherServlet's ViewResolvermodel
- Map of model names (Strings) to model objects (Objects). Model entries may not benull
, but the model Map may benull
if there is no model data.
-
ModelAndMustacheView
public ModelAndMustacheView(MustacheView view, Map<String,?> model)
Creates new ModelAndView given a View object and a model. Note: the supplied model data is copied into the internal storage of this class. You should not consider to modify the supplied Map after supplying it to this class- Parameters:
view
- View object to rendermodel
- Map of model names (Strings) to model objects (Objects). Model entries may not benull
, but the model Map may benull
if there is no model data.
-
ModelAndMustacheView
public ModelAndMustacheView(String viewName, String modelName, Object modelObject)
Convenient constructor to take a single model object.- Parameters:
viewName
- name of the View to render, to be resolved by the DispatcherServlet's ViewResolvermodelName
- name of the single entry in the modelmodelObject
- the single model object
-
ModelAndMustacheView
public ModelAndMustacheView(MustacheView view, String modelName, Object modelObject)
Convenient constructor to take a single model object.- Parameters:
view
- View object to rendermodelName
- name of the single entry in the modelmodelObject
- the single model object
-
-