org.springframework.web.reactive.result.view

## Class AbstractView

- java.lang.Object
- - org.springframework.web.reactive.result.view.AbstractView

All Implemented Interfaces:
  org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware, View

Direct Known Subclasses:
  AbstractUrlBasedView

    public abstract class AbstractView
    extends Object
    implements View, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware

Base class for `View` implementations.

Since:
  5.0
Author:
  Rossen Stoyanchev, Sam Brannen

### Field Summary

Fields
`protected Log` `logger` Logger that is available to subclasses.
`static String` `REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME` Well-known name for the RequestDataValueProcessor in the bean factory.

### Fields inherited from interface org.springframework.web.reactive.result.view.View

`BINDING_CONTEXT_ATTRIBUTE`

### Constructor Summary

Constructors
Constructor and Description
`AbstractView()`
`AbstractView(org.springframework.core.ReactiveAdapterRegistry reactiveAdapterRegistry)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
`protected RequestContext` `createRequestContext(org.springframework.web.server.ServerWebExchange exchange, Map<String,Object> model)` Create a `RequestContext` to expose under the specified attribute name.
`protected String` `formatViewName()`
`org.springframework.context.ApplicationContext` `getApplicationContext()`
`String` `getBeanName()` Get the view's name.
`Charset` `getDefaultCharset()` Get the default charset, used when the content type does not contain one.
`protected reactor.core.publisher.Mono<Map<String,Object>>` `getModelAttributes(Map<String,?> model, org.springframework.web.server.ServerWebExchange exchange)` Prepare the model to use for rendering.
`String` `getRequestContextAttribute()` Get the name of the `RequestContext` attribute for this view, if any.
`protected RequestDataValueProcessor` `getRequestDataValueProcessor()` Get the `RequestDataValueProcessor` to use.
`List<org.springframework.http.MediaType>` `getSupportedMediaTypes()` Get the configured media types supported by this view.
`protected org.springframework.context.ApplicationContext` `obtainApplicationContext()` Obtain the `ApplicationContext` for actual use.
`reactor.core.publisher.Mono<Void>` `render(Map<String,?> model, org.springframework.http.MediaType contentType, org.springframework.web.server.ServerWebExchange exchange)` Prepare the model to render.
`protected abstract reactor.core.publisher.Mono<Void>` `renderInternal(Map<String,Object> renderAttributes, org.springframework.http.MediaType contentType, org.springframework.web.server.ServerWebExchange exchange)` Subclasses must implement this method to actually render the view.
`protected reactor.core.publisher.Mono<Void>` `resolveAsyncAttributes(Map<String,Object> model)` Deprecated. as of 5.1.8 this method is still invoked but it is a no-op. Please use `resolveAsyncAttributes(Map, ServerWebExchange)` instead. It is invoked after this one and does the actual work.
`protected reactor.core.publisher.Mono<Void>` `resolveAsyncAttributes(Map<String,Object> model, org.springframework.web.server.ServerWebExchange exchange)` Use the configured `ReactiveAdapterRegistry` to adapt asynchronous attributes to `Mono<T>` or `Mono<List<T>>` and then wait to resolve them into actual values.
`void` `setApplicationContext(org.springframework.context.ApplicationContext applicationContext)`
`void` `setBeanName(String beanName)` Set the view's name.
`void` `setDefaultCharset(Charset defaultCharset)` Set the default charset for this view, used when the content type does not contain one.
`void` `setRequestContextAttribute(String requestContextAttribute)` Set the name of the `RequestContext` attribute for this view.
`void` `setSupportedMediaTypes(List<org.springframework.http.MediaType> supportedMediaTypes)` Set the supported media types for this view.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.web.reactive.result.view.View

`isRedirectView`

### Field Detail

#### REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME

    public static final String REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME

Well-known name for the RequestDataValueProcessor in the bean factory.

See Also:
  Constant Field Values

#### logger

    protected final Log logger

Logger that is available to subclasses.

### Constructor Detail

#### AbstractView

    public AbstractView()

#### AbstractView

    public AbstractView(org.springframework.core.ReactiveAdapterRegistry reactiveAdapterRegistry)

### Method Detail

#### setSupportedMediaTypes

    public void setSupportedMediaTypes(List<org.springframework.http.MediaType> supportedMediaTypes)

Set the supported media types for this view.

Default is `"text/html;charset=UTF-8"`.

#### getSupportedMediaTypes

    public List<org.springframework.http.MediaType> getSupportedMediaTypes()

Get the configured media types supported by this view.

Specified by:
  `getSupportedMediaTypes` in interface `View`

#### setDefaultCharset

    public void setDefaultCharset(Charset defaultCharset)

Set the default charset for this view, used when the content type does not contain one.

Default is UTF 8.

#### getDefaultCharset

    public Charset getDefaultCharset()

Get the default charset, used when the content type does not contain one.

#### setRequestContextAttribute

    public void setRequestContextAttribute(@Nullable
                                           String requestContextAttribute)

Set the name of the `RequestContext` attribute for this view.

Default is none (`null`).

#### getRequestContextAttribute

    @Nullable
    public String getRequestContextAttribute()

Get the name of the `RequestContext` attribute for this view, if any.

#### setBeanName

    public void setBeanName(@Nullable
                            String beanName)

Set the view's name. Helpful for traceability.

Framework code must call this when constructing views.

Specified by:
  `setBeanName` in interface `org.springframework.beans.factory.BeanNameAware`

#### getBeanName

    @Nullable
    public String getBeanName()

Get the view's name.

Should never be `null` if the view was correctly configured.

#### setApplicationContext

    public void setApplicationContext(@Nullable
                                      org.springframework.context.ApplicationContext applicationContext)

Specified by:
  `setApplicationContext` in interface `org.springframework.context.ApplicationContextAware`

#### getApplicationContext

    @Nullable
    public org.springframework.context.ApplicationContext getApplicationContext()

#### obtainApplicationContext

    protected final org.springframework.context.ApplicationContext obtainApplicationContext()

Obtain the `ApplicationContext` for actual use.

Returns:
  the `ApplicationContext` (never `null`)
Throws:
  `IllegalStateException` - if the ApplicationContext cannot be obtained
See Also:
  `getApplicationContext()`

#### render

    public reactor.core.publisher.Mono<Void> render(@Nullable
                                                    Map<String,?> model,
                                                    @Nullable
                                                    org.springframework.http.MediaType contentType,
                                                    org.springframework.web.server.ServerWebExchange exchange)

Prepare the model to render.

Specified by:
  `render` in interface `View`
Parameters:
  `model` - a map with attribute names as keys and corresponding model objects as values (the map can also be `null` in 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 `Mono` that represents when and if rendering succeeds

#### getModelAttributes

    protected reactor.core.publisher.Mono<Map<String,Object>> getModelAttributes(@Nullable
                                                                                 Map<String,?> model,
                                                                                 org.springframework.web.server.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.

#### resolveAsyncAttributes

    protected reactor.core.publisher.Mono<Void> resolveAsyncAttributes(Map<String,Object> model,
                                                                       org.springframework.web.server.ServerWebExchange exchange)

Use the configured `ReactiveAdapterRegistry` to adapt asynchronous attributes to `Mono<T>` or `Mono<List<T>>` and then wait to resolve them into actual values. When the returned `Mono<Void>` completes, the asynchronous attributes in the model will have been replaced with their corresponding resolved values.

Returns:
  result a `Mono` that completes when the model is ready
Since:
  5.1.8

#### resolveAsyncAttributes

    @Deprecated
    protected reactor.core.publisher.Mono<Void> resolveAsyncAttributes(Map<String,Object> model)

Deprecated. as of 5.1.8 this method is still invoked but it is a no-op. Please use `resolveAsyncAttributes(Map, ServerWebExchange)` instead. It is invoked after this one and does the actual work.
Use the configured `ReactiveAdapterRegistry` to adapt asynchronous attributes to `Mono<T>` or `Mono<List<T>>` and then wait to resolve them into actual values. When the returned `Mono<Void>` completes, the asynchronous attributes in the model would have been replaced with their corresponding resolved values.

Returns:
  result `Mono` that completes when the model is ready

#### createRequestContext

    protected RequestContext createRequestContext(org.springframework.web.server.ServerWebExchange exchange,
                                                  Map<String,Object> model)

Create a `RequestContext` to expose under the specified attribute name.

The default implementation creates a standard `RequestContext` instance 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 `RequestContext` instance
See Also:
  `setRequestContextAttribute(java.lang.String)`

#### getRequestDataValueProcessor

    @Nullable
    protected RequestDataValueProcessor getRequestDataValueProcessor()

Get the `RequestDataValueProcessor` to use.

The default implementation looks in the `ApplicationContext` for a `RequestDataValueProcessor` bean with the name `REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME`.

Returns:
  the `RequestDataValueProcessor`, or `null` if there is none in the application context

#### renderInternal

    protected abstract reactor.core.publisher.Mono<Void> renderInternal(Map<String,Object> renderAttributes,
                                                                        @Nullable
                                                                        org.springframework.http.MediaType contentType,
                                                                        org.springframework.web.server.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 `Mono` that represents when and if rendering succeeds

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### formatViewName

    protected String formatViewName()