Class HtmxView
java.lang.Object
io.github.wimdeblauwe.htmx.spring.boot.mvc.HtmxView
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
ConstructorsConstructorDescriptionHtmxView()Create a new HtmxView.Create a new HtmxView with the given view names.HtmxView(org.springframework.web.servlet.ModelAndView... mavs) Create a new HtmxView with the given ModelAndViewsHtmxView(org.springframework.web.servlet.View... views) Create a new HtmxView with the given Views. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a ModelAndView with the given view name to the list of views to render.voidAdd a ModelAndView with the given view name and a model to the list of views to render.voidadd(org.springframework.web.servlet.ModelAndView mav) Add a ModelAndView to the list of views to render.voidadd(org.springframework.web.servlet.View view) Add a ModelAndView with the given View to the list of views to render.voidAdd a ModelAndView with the given View to the list of views to render.Set<org.springframework.web.servlet.ModelAndView>getViews()Return the views to render.
-
Constructor Details
-
HtmxView
public HtmxView()Create a new HtmxView. -
HtmxView
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
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
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 ViewResolvermodel- a Map of model names (Strings) to model objects (Objects). Model entries may not benull, but the model Map may benullif 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
Add a ModelAndView with the given View to the list of views to render.- Parameters:
view- the View object to rendermodel- a Map of model names (Strings) to model objects (Objects). Model entries may not benull, but the model Map may benullif 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
Return the views to render.- Returns:
- the views
-