Interface FragmentsRendering
public interface FragmentsRendering
Public API to render HTML fragments. A fragment is a portion of an HTML page.
Normally HTML is rendered with a single model and view. This API allows
using multiple model and view pairs, one for each HTML fragment.
For use with frontends technologies such as htmx where multiple page fragments may be rendered in one response.
Supported as a return value from annotated controller methods.
For full page rendering with a single model and view, use Rendering
.
- Since:
- 6.2
- Author:
- Rossen Stoyanchev
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic FragmentsRendering.Builder
Create a builder with one HTML fragment, also inheriting attributes from the shared model for the request.static FragmentsRendering.Builder
Create a builder with one HTML fragment.reactor.core.publisher.Flux<Fragment>
Return the fragments to render.static FragmentsRendering.Builder
fragments
(Collection<Fragment> fragments) Create a builder with multiple HTML fragments.static FragmentsRendering.Builder
fragmentsProducer
(Object fragmentsProducer) Variant offragmentsPublisher(Publisher)
that allows using any producer that can be resolved toPublisher
viaReactiveAdapterRegistry
.static <P extends Publisher<Fragment>>
FragmentsRendering.BuilderfragmentsPublisher
(P fragmentsPublisher) Create a builder with aPublisher
of fragments.headers()
Return headers to add to the response.status()
Return the HTTP status to set the response to.
-
Method Details
-
status
@Nullable HttpStatusCode status()Return the HTTP status to set the response to. -
headers
HttpHeaders headers()Return headers to add to the response. -
fragments
reactor.core.publisher.Flux<Fragment> fragments()Return the fragments to render. -
fragment
Create a builder with one HTML fragment, also inheriting attributes from the shared model for the request.- Parameters:
viewName
- the name of the view for the fragment- Returns:
- this builder
- Since:
- 6.2.1
-
fragment
Create a builder with one HTML fragment.- Parameters:
viewName
- the view name for the fragmentmodel
- attributes for the fragment, in addition to attributes from the shared model for the request- Returns:
- this builder
- Since:
- 6.2.1
-
fragments
Create a builder with multiple HTML fragments.- Parameters:
fragments
- the fragments to add; each fragment also inherits attributes from the shared model for the request- Returns:
- the created builder
- Since:
- 6.2.1
-
fragmentsPublisher
static <P extends Publisher<Fragment>> FragmentsRendering.Builder fragmentsPublisher(P fragmentsPublisher) Create a builder with aPublisher
of fragments.- Parameters:
fragmentsPublisher
- the fragments to add; each fragment also inherits model attributes from the shared model for the request- Returns:
- the created builder
- Since:
- 6.2.1
-
fragmentsProducer
Variant offragmentsPublisher(Publisher)
that allows using any producer that can be resolved toPublisher
viaReactiveAdapterRegistry
.- Since:
- 6.2.1
-