FragmentsRendering exposes its fragments

Closes gh-35775
This commit is contained in:
rstoyanchev
2025-12-01 11:20:43 +00:00
parent 67a92306f7
commit 2144813bad
2 changed files with 14 additions and 1 deletions
@@ -19,6 +19,7 @@ package org.springframework.web.servlet.view;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
@@ -59,7 +60,7 @@ final class DefaultFragmentsRendering implements FragmentsRendering {
this.status = status;
this.headers = headers;
this.modelAndViews = new ArrayList<>(fragments);
this.modelAndViews = Collections.unmodifiableCollection(new ArrayList<>(fragments));
}
@@ -79,6 +80,12 @@ final class DefaultFragmentsRendering implements FragmentsRendering {
return false;
}
@Override
public Collection<ModelAndView> fragments() {
return this.modelAndViews;
}
@Override
public void resolveNestedViews(ViewResolver resolver, Locale locale) throws Exception {
for (ModelAndView mv : this.modelAndViews) {
@@ -53,6 +53,12 @@ public interface FragmentsRendering extends SmartView {
*/
HttpHeaders headers();
/**
* Return the {@code ModelAndView} for each fragment.
* @since 6.2.15
*/
Collection<ModelAndView> fragments();
/**
* Create a builder with one HTML fragment, also inheriting attributes from