public abstract class AbstractView extends Object implements View, ApplicationContextAware
View implementations.| Modifier and Type | Field and Description |
|---|---|
protected Log |
logger
Logger that is available to subclasses
|
| Constructor and Description |
|---|
AbstractView() |
| Modifier and Type | Method and Description |
|---|---|
ApplicationContext |
getApplicationContext() |
protected Map<String,Object> |
getModelAttributes(HandlerResult result,
ServerWebExchange exchange)
Prepare the model to use for rendering.
|
List<MediaType> |
getSupportedMediaTypes()
Return the configured media types supported by this view.
|
reactor.core.publisher.Mono<Void> |
render(HandlerResult result,
MediaType contentType,
ServerWebExchange exchange)
Prepare the model to render.
|
protected abstract reactor.core.publisher.Mono<Void> |
renderInternal(Map<String,Object> renderAttributes,
ServerWebExchange exchange)
Subclasses must implement this method to actually render the view.
|
void |
setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in.
|
void |
setSupportedMediaTypes(List<MediaType> supportedMediaTypes)
Set the supported media types for this view.
|
String |
toString() |
protected final Log logger
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes)
public List<MediaType> getSupportedMediaTypes()
getSupportedMediaTypes in interface Viewpublic void setApplicationContext(ApplicationContext applicationContext)
ApplicationContextAwareInvoked after population of normal bean properties but before an init callback such
as InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked after ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader),
ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) and
MessageSourceAware, if applicable.
setApplicationContext in interface ApplicationContextAwareapplicationContext - the ApplicationContext object to be used by this objectBeanInitializationExceptionpublic ApplicationContext getApplicationContext()
public reactor.core.publisher.Mono<Void> render(HandlerResult result, MediaType contentType, ServerWebExchange exchange)
render in interface Viewresult - the result from handler executioncontentType - the content type selected to render with which should
match one of the supported media types.exchange - the current exchangeMono to represent when and if rendering succeedsprotected Map<String,Object> getModelAttributes(HandlerResult result, ServerWebExchange exchange)
The default implementation creates a combined output Map that includes model as well as static attributes with the former taking precedence.
protected abstract reactor.core.publisher.Mono<Void> renderInternal(Map<String,Object> renderAttributes, ServerWebExchange exchange)
renderAttributes - combined output Map (never null),
with dynamic values taking precedence over static attributesexchange - current exchangeMono to represent when and if rendering succeeds