java.lang.Object
io.github.wimdeblauwe.htmx.spring.boot.mvc.HtmxView

public class HtmxView extends Object
View that can be used to return multiple views as fragments to be rendered together.

In Spring MVC, view rendering typically involves specifying one view and one model. However, in htmx a common capability is to send multiple HTML fragments that the browser can use to update different parts of the page. For this, controller methods can return this class.

Since:
3.6.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new HtmxView.
    HtmxView(String... viewNames)
    Create a new HtmxView with the given view names.
    HtmxView(org.springframework.web.servlet.ModelAndView... mavs)
    Create a new HtmxView with the given ModelAndViews
    HtmxView(org.springframework.web.servlet.View... views)
    Create a new HtmxView with the given Views.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String viewName)
    Add a ModelAndView with the given view name to the list of views to render.
    void
    add(String viewName, Map<String,?> model)
    Add a ModelAndView with the given view name and a model to the list of views to render.
    void
    add(org.springframework.web.servlet.ModelAndView mav)
    Add a ModelAndView to the list of views to render.
    void
    add(org.springframework.web.servlet.View view)
    Add a ModelAndView with the given View to the list of views to render.
    void
    add(org.springframework.web.servlet.View view, Map<String,?> model)
    Add a ModelAndView with the given View to the list of views to render.
    Set<org.springframework.web.servlet.ModelAndView>
    Return the views to render.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HtmxView

      public HtmxView()
      Create a new HtmxView.
    • HtmxView

      public HtmxView(String... viewNames)
      Create a new HtmxView with the given view names.
      Parameters:
      viewNames - the view names
    • HtmxView

      public HtmxView(org.springframework.web.servlet.View... views)
      Create a new HtmxView with the given Views.
      Parameters:
      views - the views
    • HtmxView

      public HtmxView(org.springframework.web.servlet.ModelAndView... mavs)
      Create a new HtmxView with the given ModelAndViews
      Parameters:
      mavs -
  • Method Details

    • add

      public void add(String viewName)
      Add a ModelAndView with the given view name to the list of views to render.
      Parameters:
      viewName - name of the View to render, to be resolved by the DispatcherServlet's ViewResolver
    • add

      public void add(String viewName, @Nullable Map<String,?> model)
      Add a ModelAndView with the given view name and a model to the list of views to render.
      Parameters:
      viewName - name of the View to render, to be resolved by the DispatcherServlet's ViewResolver
      model - a 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.
    • add

      public void add(org.springframework.web.servlet.View view)
      Add a ModelAndView with the given View to the list of views to render.
      Parameters:
      view - the View object to render
    • add

      public void add(org.springframework.web.servlet.View view, @Nullable Map<String,?> model)
      Add a ModelAndView with the given View to the list of views to render.
      Parameters:
      view - the View object to render
      model - a 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.
    • add

      public void add(org.springframework.web.servlet.ModelAndView mav)
      Add a ModelAndView to the list of views to render.
      Parameters:
      mav - the ModelAndView
    • getViews

      public Set<org.springframework.web.servlet.ModelAndView> getViews()
      Return the views to render.
      Returns:
      the views