Class ModelAndMustacheView


  • public class ModelAndMustacheView
    extends org.springframework.web.servlet.ModelAndView
    Extension of ModelAndView class that provide shortcuts to get and add partial mappings that will be used to render 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 with addObject.
        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 with addObject.
        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 ViewResolver
        model - Map of model names (Strings) to model objects (Objects). Model entries may not be null, but the model Map may be null 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 render
        model - Map of model names (Strings) to model objects (Objects). Model entries may not be null, but the model Map may be null 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 ViewResolver
        modelName - name of the single entry in the model
        modelObject - 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 render
        modelName - name of the single entry in the model
        modelObject - the single model object
    • Method Detail

      • getPartials

        public Map<String,​String> getPartials()
        Get current partials stored in view.
        Returns:
        Current partials.
      • addPartial

        public void addPartial​(String key,
                               String name)
        Add new partials mapping to the view.
        Parameters:
        key - Partial name.
        name - Partial path.
      • addPartials

        public void addPartials​(Map<String,​String> partials)
        Add new partials mapping to the view.
        Parameters:
        partials - Partials.