Class AbstractView
- All Implemented Interfaces:
- Aware, BeanNameAware, ApplicationContextAware, View
- Direct Known Subclasses:
- AbstractUrlBasedView
View implementations.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Sam Brannen
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final org.apache.commons.logging.LogLogger that is available to subclasses.static final StringWell-known name for the RequestDataValueProcessor in the bean factory.Fields inherited from interface ViewBINDING_CONTEXT_ATTRIBUTE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected RequestContextcreateRequestContext(ServerWebExchange exchange, Map<String, Object> model) Create aRequestContextto expose under the specified attribute name.protected StringGet the view's name.Get the default charset, used when the content type does not contain one.getModelAttributes(@Nullable Map<String, ?> model, ServerWebExchange exchange) Prepare the model to use for rendering.Get the name of theRequestContextattribute for this view, if any.protected @Nullable RequestDataValueProcessorGet theRequestDataValueProcessorto use.Get the configured media types supported by this view.protected final ApplicationContextObtain theApplicationContextfor actual use.reactor.core.publisher.Mono<Void> Prepare the model to render.protected abstract reactor.core.publisher.Mono<Void> renderInternal(Map<String, Object> renderAttributes, @Nullable MediaType contentType, ServerWebExchange exchange) Subclasses must implement this method to actually render the view.protected reactor.core.publisher.Mono<Void> resolveAsyncAttributes(Map<String, Object> model, ServerWebExchange exchange) Use the configuredReactiveAdapterRegistryto adapt asynchronous attributes toMono<T>orMono<List<T>>and then wait to resolve them into actual values.voidsetApplicationContext(@Nullable ApplicationContext applicationContext) Set the ApplicationContext that this object runs in.voidsetBeanName(@Nullable String beanName) Set the view's name.voidsetDefaultCharset(Charset defaultCharset) Set the default charset for this view, used when the content type does not contain one.voidsetRequestContextAttribute(@Nullable String requestContextAttribute) Set the name of theRequestContextattribute for this view.voidsetSupportedMediaTypes(List<MediaType> supportedMediaTypes) Set the supported media types for this view.toString()Methods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ViewisRedirectView
- 
Field Details- 
REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAMEWell-known name for the RequestDataValueProcessor in the bean factory.- See Also:
 
- 
loggerprotected final org.apache.commons.logging.Log loggerLogger that is available to subclasses.
 
- 
- 
Constructor Details- 
AbstractViewpublic AbstractView()
- 
AbstractView
 
- 
- 
Method Details- 
setSupportedMediaTypes
- 
getSupportedMediaTypesGet the configured media types supported by this view.- Specified by:
- getSupportedMediaTypesin interface- View
 
- 
setDefaultCharsetSet the default charset for this view, used when the content type does not contain one.Default is UTF 8. 
- 
getDefaultCharsetGet the default charset, used when the content type does not contain one.
- 
setRequestContextAttribute
- 
getRequestContextAttribute
- 
setBeanNameSet the view's name. Helpful for traceability.Framework code must call this when constructing views. - Specified by:
- setBeanNamein interface- BeanNameAware
- Parameters:
- beanName- the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the- BeanFactoryUtils.originalBeanName(String)method to extract the original bean name (without suffix), if desired.
 
- 
getBeanName
- 
setApplicationContextDescription copied from interface:ApplicationContextAwareSet the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.Invoked after population of normal bean properties but before an init callback such as InitializingBean.afterPropertiesSet()or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(ResourceLoader),ApplicationEventPublisherAware.setApplicationEventPublisher(ApplicationEventPublisher)andMessageSourceAware, if applicable.- Specified by:
- setApplicationContextin interface- ApplicationContextAware
- Parameters:
- applicationContext- the ApplicationContext object to be used by this object
- See Also:
 
- 
getApplicationContext
- 
obtainApplicationContextObtain theApplicationContextfor actual use.- Returns:
- the ApplicationContext(nevernull)
- Throws:
- IllegalStateException- if the ApplicationContext cannot be obtained
- See Also:
 
- 
renderpublic reactor.core.publisher.Mono<Void> render(@Nullable Map<String, ?> model, @Nullable MediaType contentType, ServerWebExchange exchange) Prepare the model to render.- Specified by:
- renderin interface- View
- Parameters:
- model- a map with attribute names as keys and corresponding model objects as values (the map can also be- nullin case of an empty model)
- contentType- the content type selected to render with, which should match one of the- supported media types
- exchange- the current exchange
- Returns:
- a Monothat represents when and if rendering succeeds
 
- 
getModelAttributesprotected reactor.core.publisher.Mono<Map<String,Object>> getModelAttributes(@Nullable Map<String, ?> model, ServerWebExchange exchange) Prepare the model to use for rendering.The default implementation creates a combined output Map that includes model as well as static attributes with the former taking precedence. 
- 
resolveAsyncAttributesprotected reactor.core.publisher.Mono<Void> resolveAsyncAttributes(Map<String, Object> model, ServerWebExchange exchange) Use the configuredReactiveAdapterRegistryto adapt asynchronous attributes toMono<T>orMono<List<T>>and then wait to resolve them into actual values. When the returnedMono<Void>completes, the asynchronous attributes in the model will have been replaced with their corresponding resolved values.- Returns:
- result a Monothat completes when the model is ready
- Since:
- 5.1.8
 
- 
createRequestContextCreate aRequestContextto expose under the specified attribute name.The default implementation creates a standard RequestContextinstance for the given exchange and model.Can be overridden in subclasses to create custom instances. - Parameters:
- exchange- the current exchange
- model- a combined output Map (never- null), with dynamic values taking precedence over static attributes
- Returns:
- the RequestContextinstance
- See Also:
 
- 
getRequestDataValueProcessorGet theRequestDataValueProcessorto use.The default implementation looks in the ApplicationContextfor aRequestDataValueProcessorbean with the nameREQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME.- Returns:
- the RequestDataValueProcessor, ornullif there is none in the application context
 
- 
renderInternalprotected abstract reactor.core.publisher.Mono<Void> renderInternal(Map<String, Object> renderAttributes, @Nullable MediaType contentType, ServerWebExchange exchange) Subclasses must implement this method to actually render the view.- Parameters:
- renderAttributes- combined output Map (never- null), with dynamic values taking precedence over static attributes
- contentType- the content type selected to render with, which should match one of the supported media types
- exchange- current exchange
- Returns:
- a Monothat represents when and if rendering succeeds
 
- 
toString
- 
formatViewName
 
-