Module io.jooby
Package io.jooby

Class ModelAndView

java.lang.Object
io.jooby.ModelAndView

public class ModelAndView extends Object
Used by template engines to renderer views.
Since:
2.0.0
Author:
edgar
  • Constructor Details

    • ModelAndView

      public ModelAndView(@NonNull String view, @NonNull Map<String,Object> model)
      Creates a new model and view.
      Parameters:
      view - View name must include file extension.
      model - View model.
    • ModelAndView

      public ModelAndView(@NonNull String view)
      Creates a new model and view.
      Parameters:
      view - View name must include file extension.
  • Method Details

    • put

      public ModelAndView put(@NonNull String name, Object value)
      Put a model attribute.
      Parameters:
      name - Name.
      value - Value.
      Returns:
      This model and view.
    • put

      public ModelAndView put(@NonNull Map<String,Object> attributes)
      Copy all the attributes into the model.
      Parameters:
      attributes - Attributes.
      Returns:
      This model and view.
    • setLocale

      public ModelAndView setLocale(@Nullable Locale locale)
      Sets the locale used when rendering the view, if the template engine supports setting it. Specifying null triggers a fallback to a locale determined by the current request.
      Parameters:
      locale - The locale used when rendering the view.
      Returns:
      This instance.
    • getModel

      public Map<String,Object> getModel()
      View data (a.k.a as model).
      Returns:
      View data (a.k.a as model).
    • getView

      public String getView()
      View name with file extension, like: index.html.
      Returns:
      View name with file extension, like: index.html.
    • getLocale

      @Nullable public Locale getLocale()
      Returns the locale used when rendering the view. Defaults to null, which triggers a fallback to a locale determined by the current request.
      Returns:
      The locale used when rendering the view.
    • toString

      public String toString()
      Overrides:
      toString in class Object