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() |
Charset |
getDefaultCharset()
Return the default charset, used when the
content type does not contain one.
|
protected Map<String,Object> |
getModelAttributes(Map<String,?> model,
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(Map<String,?> model,
MediaType contentType,
ServerWebExchange exchange)
Prepare the model to render.
|
protected abstract reactor.core.publisher.Mono<Void> |
renderInternal(Map<String,Object> renderAttributes,
MediaType contentType,
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 |
setDefaultCharset(Charset defaultCharset)
Set the default charset for this view, used when the
content type does not contain one.
|
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 View
public void setDefaultCharset(Charset defaultCharset)
public Charset getDefaultCharset()
public void setApplicationContext(ApplicationContext applicationContext)
ApplicationContextAware
Invoked 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 ApplicationContextAware
applicationContext
- the ApplicationContext object to be used by this objectBeanInitializationException
public ApplicationContext getApplicationContext()
public reactor.core.publisher.Mono<Void> render(Map<String,?> model, MediaType contentType, ServerWebExchange exchange)
render
in interface View
model
- Map with name Strings as keys and corresponding model
objects as values (Map can also be null
in case of empty model)contentType
- 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(Map<String,?> model, 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, MediaType contentType, ServerWebExchange exchange)
renderAttributes
- combined output Map (never null
),
with dynamic values taking precedence over static attributescontentType
- the content type selected to render with which should
match one of the supported media types
.exchange
- current exchange @return Mono
to represent when and if rendering succeeds