Skip to content

Commit 1fd0b87

Browse files
committed
Improve Javadoc of FragmentsRendering
1 parent 1164ac3 commit 1fd0b87

File tree

3 files changed

+49
-45
lines changed

3 files changed

+49
-45
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/result/view/Fragment.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
import org.springframework.util.CollectionUtils;
2727

2828
/**
29-
* Container for a model and a view for use with {@link FragmentsRendering} and
30-
* multi-view rendering. For full page rendering with a single model and view,
31-
* use {@link Rendering}.
29+
* Container for a model and a view pair. For use with {@link FragmentsRendering}.
3230
*
3331
* @author Rossen Stoyanchev
3432
* @since 6.2

spring-webflux/src/main/java/org/springframework/web/reactive/result/view/FragmentsRendering.java

+24-22
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@
3232
import org.springframework.util.Assert;
3333

3434
/**
35-
* Public API for HTML rendering of a collection of fragments each with a view
36-
* and independent model. For use with frontends technologies such as
35+
* Public API to render HTML fragments. A fragment is a portion of an HTML page.
36+
* Normally HTML is rendered with a single model and view. This API allows
37+
* using multiple model and view pairs, one for each HTML fragment.
38+
*
39+
* <p>For use with frontends technologies such as
3740
* <a href="https://htmx.org/">htmx</a> where multiple page fragments may be
38-
* rendered in one response. Supported as a return value from Spring WebFlux
39-
* controller methods.
41+
* rendered in one response.
4042
*
41-
* <p>For full page rendering with a single model and view, use {@link Rendering}.
43+
* <p>Supported as a return value from annotated controller methods.
44+
* For full page rendering with a single model and view, use {@link Rendering}.
4245
*
4346
* @author Rossen Stoyanchev
4447
* @since 6.2
@@ -63,19 +66,19 @@ public interface FragmentsRendering {
6366

6467

6568
/**
66-
* Create a builder and add a fragment with a view name and a model.
67-
* @param viewName the name of the view for the fragment
68-
* @param model attributes for the fragment in addition to model
69-
* attributes inherited from the model for the request
69+
* Create a builder with one HTML fragment.
70+
* @param viewName the view name for the fragment
71+
* @param model attributes for the fragment, in addition to attributes from the
72+
* shared model for the request
7073
* @return this builder
7174
*/
7275
static Builder with(String viewName, Map<String, Object> model) {
7376
return withCollection(List.of(Fragment.create(viewName, model)));
7477
}
7578

7679
/**
77-
* Variant of {@link #with(String, Map)} with a view name only, but also
78-
* inheriting model attributes from the shared model for the request.
80+
* Create a builder with one HTML fragment, also inheriting attributes from
81+
* the shared model for the request.
7982
* @param viewName the name of the view for the fragment
8083
* @return this builder
8184
*/
@@ -84,8 +87,8 @@ static Builder with(String viewName) {
8487
}
8588

8689
/**
87-
* Variant of {@link #with(String, Map)} with a collection of fragments.
88-
* @param fragments the fragments to add; each fragment also inherits model
90+
* Create a builder with multiple HTML fragments.
91+
* @param fragments the fragments to add; each fragment also inherits
8992
* attributes from the shared model for the request
9093
* @return the created builder
9194
*/
@@ -94,7 +97,7 @@ static Builder withCollection(Collection<Fragment> fragments) {
9497
}
9598

9699
/**
97-
* Variant of {@link #with(String, Map)} with a {@link Publisher} of fragments.
100+
* Create a builder with a {@link Publisher} of fragments.
98101
* @param fragmentsPublisher the fragments to add; each fragment also
99102
* inherits model attributes from the shared model for the request
100103
* @return the created builder
@@ -148,25 +151,24 @@ interface Builder {
148151
Builder headers(Consumer<HttpHeaders> headersConsumer);
149152

150153
/**
151-
* Add a fragment with a view name and a model.
152-
* @param viewName the name of the view for the fragment
153-
* @param model attributes for the fragment in addition to model
154-
* attributes inherited from the model for the request
154+
* Add an HTML fragment.
155+
* @param viewName the view name for the fragment
156+
* @param model fragment attributes in addition to attributes from the
157+
* shared model for the request
155158
* @return this builder
156159
*/
157160
Builder fragment(String viewName, Map<String, Object> model);
158161

159162
/**
160-
* Variant of {@link #fragment(String, Map)} with a view name only, where
161-
* the fragment model also inherits model attributes from the shared
163+
* Add an HTML fragment. The fragment will use attributes from the shared
162164
* model for the request.
163-
* @param viewName the name of the view for the fragment
165+
* @param viewName the view name for the fragment
164166
* @return this builder
165167
*/
166168
Builder fragment(String viewName);
167169

168170
/**
169-
* Variant of {@link #fragment(String, Map)} with a {@link Fragment}.
171+
* Add an HTML fragment.
170172
* @param fragment the fragment to add
171173
* @return this builder
172174
*/

spring-webmvc/src/main/java/org/springframework/web/servlet/view/FragmentsRendering.java

+24-20
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@
2727
import org.springframework.web.servlet.SmartView;
2828

2929
/**
30-
* Public API for HTML rendering of a collection of fragments each with a view
31-
* and independent model. For use with frontends technologies such as
30+
* Public API to render HTML fragments. A fragment is a portion of an HTML page.
31+
* Normally HTML is rendered with a single model and view. This API allows
32+
* using multiple model and view pairs, one for each HTML fragment.
33+
*
34+
* <p>For use with frontends technologies such as
3235
* <a href="https://htmx.org/">htmx</a> where multiple page fragments may be
33-
* rendered in one response. Supported as a return value from Spring MVC
34-
* controller methods.
36+
* rendered in one response.
37+
*
38+
* <p>Supported as a return value from controller methods.
3539
*
3640
* @author Rossen Stoyanchev
3741
* @since 6.2
@@ -51,19 +55,19 @@ public interface FragmentsRendering extends SmartView {
5155

5256

5357
/**
54-
* Create a builder and add a fragment with a view name and a model.
55-
* @param viewName the name of the view for the fragment
56-
* @param model attributes for the fragment in addition to model
57-
* attributes inherited from the shared model for the request
58+
* Create a builder with one HTML fragment.
59+
* @param viewName the view name for the fragment
60+
* @param model attributes for the fragment, in addition to attributes from the
61+
* shared model for the request
5862
* @return the created builder
5963
*/
6064
static Builder with(String viewName, Map<String, Object> model) {
6165
return new DefaultFragmentsRenderingBuilder().fragment(viewName, model);
6266
}
6367

6468
/**
65-
* Variant of {@link #with(String, Map)} with a view name only, but also
66-
* inheriting model attributes from the shared model for the request.
69+
* Create a builder with one HTML fragment, also inheriting attributes from
70+
* the shared model for the request.
6771
* @param viewName the name of the view for the fragment
6872
* @return the created builder
6973
*/
@@ -72,8 +76,8 @@ static Builder with(String viewName) {
7276
}
7377

7478
/**
75-
* Variant of {@link #with(String, Map)} with a collection of fragments.
76-
* @param fragments the fragments to add; each fragment also inherits model
79+
* Create a builder with multiple HTML fragments.
80+
* @param fragments the fragments to add; each fragment also inherits
7781
* attributes from the shared model for the request
7882
* @return the created builder
7983
*/
@@ -111,32 +115,32 @@ interface Builder {
111115
Builder headers(Consumer<HttpHeaders> headersConsumer);
112116

113117
/**
114-
* Add a fragment with a view name and a model.
118+
* Add an HTML fragment.
115119
* @param viewName the name of the view for the fragment
116-
* @param model attributes for the fragment in addition to model
117-
* attributes inherited from the shared model for the request
120+
* @param model fragment attributes in addition to attributes from the
121+
* shared model for the request
118122
* @return this builder
119123
*/
120124
Builder fragment(String viewName, Map<String, Object> model);
121125

122126
/**
123-
* Variant of {@link #fragment(String, Map)} with a view name only, but
124-
* also inheriting model attributes from the shared model for the request.
127+
* Add an HTML fragment. The fragment will use attributes from the shared
128+
* model for the request.
125129
* @param viewName the name of the view for the fragment
126130
* @return this builder
127131
*/
128132
Builder fragment(String viewName);
129133

130134
/**
131-
* Variant of {@link #fragment(String, Map)} with a {@link ModelAndView}.
132-
* @param fragment the fragment to add; the fragment also inherits model
135+
* Add an HTML fragment.
136+
* @param fragment the fragment to add; the fragment also inherits
133137
* attributes from the shared model for the request
134138
* @return this builder
135139
*/
136140
Builder fragment(ModelAndView fragment);
137141

138142
/**
139-
* Variant of {@link #fragment(String, Map)} with a collection of {@link ModelAndView}s.
143+
* Add multiple HTML fragments.
140144
* @param fragments the fragments to add; each fragment also inherits model
141145
* attributes from the shared model for the request
142146
* @return this builder

0 commit comments

Comments
 (0)