Module io.jooby
Package io.jooby

Class ModelAndView<T>

java.lang.Object
io.jooby.ModelAndView<T>
Direct Known Subclasses:
MapModelAndView

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

    • ModelAndView

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

    • map

      public static MapModelAndView map(@NonNull String view)
      Creates a model and view backed by a map.
      Parameters:
      view - View name.
      Returns:
      A map model and view.
    • map

      public static MapModelAndView map(@NonNull String view, @NonNull Map<String,Object> model)
      Creates a model and view backed by a map.
      Parameters:
      view - View name.
      model - Map instance.
      Returns:
      A map model and view.
    • setLocale

      public ModelAndView<T> 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 T 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