Interface FragmentsRendering
public interface FragmentsRendering
Public API for HTML rendering of a collection of fragments each with a view
and independent model. For use with frontends technologies such as
htmx where multiple page fragments may be
rendered in one response. Supported as a return value from Spring WebFlux
controller methods.
For full page rendering with a single model and view, use Rendering.
- Since:
- 6.2
- Author:
- Rossen Stoyanchev
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Flux<Fragment>Return the fragments to render.headers()Return headers to add to the response.status()Return the HTTP status to set the response to.static FragmentsRendering.BuilderVariant ofwith(String, Map)with a view name only, but also inheriting model attributes from the shared model for the request.static FragmentsRendering.BuilderCreate a builder and add a fragment with a view name and a model.static FragmentsRendering.BuilderwithCollection(Collection<Fragment> fragments) Variant ofwith(String, Map)with a collection of fragments.static FragmentsRendering.BuilderwithProducer(Object fragmentsProducer) Variant ofwithPublisher(Publisher)that allows using any producer that can be resolved toPublisherviaReactiveAdapterRegistry.static <P extends Publisher<Fragment>>
FragmentsRendering.BuilderwithPublisher(P fragmentsPublisher) Variant ofwith(String, Map)with aPublisherof fragments.
-
Method Details
-
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. -
with
Create a builder and add a fragment with a view name and a model.- Parameters:
viewName- the name of the view for the fragmentmodel- attributes for the fragment in addition to model attributes inherited from the model for the request- Returns:
- this builder
-
with
Variant ofwith(String, Map)with a view name only, but also inheriting model attributes from the shared model for the request.- Parameters:
viewName- the name of the view for the fragment- Returns:
- this builder
-
withCollection
Variant ofwith(String, Map)with a collection of fragments.- Parameters:
fragments- the fragments to add; each fragment also inherits model attributes from the shared model for the request- Returns:
- the created builder
-
withPublisher
static <P extends Publisher<Fragment>> FragmentsRendering.Builder withPublisher(P fragmentsPublisher) Variant ofwith(String, Map)with aPublisherof fragments.- Parameters:
fragmentsPublisher- the fragments to add; each fragment also inherits model attributes from the shared model for the request- Returns:
- the created builder
-
withProducer
Variant ofwithPublisher(Publisher)that allows using any producer that can be resolved toPublisherviaReactiveAdapterRegistry.
-