Class ThymeleafReactiveView
- Object
-
- org.springframework.web.reactive.result.view.AbstractView
-
- org.thymeleaf.spring5.view.reactive.ThymeleafReactiveView
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.context.ApplicationContextAware
,org.springframework.web.reactive.result.view.View
public class ThymeleafReactiveView extends org.springframework.web.reactive.result.view.AbstractView implements org.springframework.beans.factory.BeanNameAware
Base implementation of the Spring WebFlux
View
interface.Views represent a template being executed, after being resolved (and instantiated) by a
ViewResolver
.This is the default view implementation resolved by
ThymeleafReactiveViewResolver
.This view needs a
ISpringWebFluxTemplateEngine
for execution, and it will call itsISpringWebFluxTemplateEngine.processStream(String, Set, IContext, DataBufferFactory, MediaType, Charset, int)
method to create the reactive data streams to be used for processing the template. See the documentation of this class to know more about the different operation modes available.- Since:
- 3.0.3
- Author:
- Daniel Fernández
- See Also:
ThymeleafReactiveViewResolver
,ISpringWebFluxTemplateEngine
,ReactiveDataDriverContextVariable
,IReactiveDataDriverContextVariable
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_RESPONSE_CHUNK_SIZE_BYTES
By default, no max response chunk size is set.protected static org.slf4j.Logger
logger
static String
REACTIVE_MODEL_ADDITIONS_EXECUTION_ATTRIBUTE_PREFIX
This prefix should be used in order to allow dialects to provide reactive stream objects that should be resolved (in an unblocked manner) just before the execution of the view.
-
Constructor Summary
Constructors Constructor Description ThymeleafReactiveView()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStaticVariable(String name, Object value)
String
getBeanName()
protected Locale
getLocale()
String
getMarkupSelector()
int
getResponseMaxChunkSizeBytes()
Map<String,Object>
getStaticVariables()
protected ISpringWebFluxTemplateEngine
getTemplateEngine()
String
getTemplateName()
reactor.core.publisher.Mono<Void>
render(Map<String,?> model, org.springframework.http.MediaType contentType, org.springframework.web.server.ServerWebExchange exchange)
protected reactor.core.publisher.Mono<Void>
renderFragmentInternal(Set<String> markupSelectorsToRender, Map<String,Object> renderAttributes, org.springframework.http.MediaType contentType, org.springframework.web.server.ServerWebExchange exchange)
protected reactor.core.publisher.Mono<Void>
renderInternal(Map<String,Object> renderAttributes, org.springframework.http.MediaType contentType, org.springframework.web.server.ServerWebExchange exchange)
void
setBeanName(String beanName)
void
setDefaultCharset(Charset defaultCharset)
protected void
setLocale(Locale locale)
void
setMarkupSelector(String markupSelector)
void
setResponseMaxChunkSizeBytes(int responseMaxBufferSizeBytes)
void
setStaticVariables(Map<String,?> variables)
void
setSupportedMediaTypes(List<org.springframework.http.MediaType> supportedMediaTypes)
protected void
setTemplateEngine(ISpringWebFluxTemplateEngine templateEngine)
void
setTemplateName(String templateName)
-
Methods inherited from class org.springframework.web.reactive.result.view.AbstractView
createRequestContext, getApplicationContext, getDefaultCharset, getModelAttributes, getRequestContextAttribute, getRequestDataValueProcessor, getSupportedMediaTypes, obtainApplicationContext, resolveAsyncAttributes, setApplicationContext, setRequestContextAttribute, toString
-
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
DEFAULT_RESPONSE_CHUNK_SIZE_BYTES
public static final int DEFAULT_RESPONSE_CHUNK_SIZE_BYTES
By default, no max response chunk size is set. Value =Integer.MAX_VALUE
- See Also:
- Constant Field Values
-
REACTIVE_MODEL_ADDITIONS_EXECUTION_ATTRIBUTE_PREFIX
public static final String REACTIVE_MODEL_ADDITIONS_EXECUTION_ATTRIBUTE_PREFIX
This prefix should be used in order to allow dialects to provide reactive stream objects that should be resolved (in an unblocked manner) just before the execution of the view. The idea is to allow these streams to be included in the standard reactive Spring view model resolution mechanisms so that Thymeleaf does not have to block during the execution of the view in order to obtain the value. The result will be as if reactive stream objects had been added by the controller methods.
The name of the attributes being added to the Model will be the name of the execution attribute minus the prefix. So
ThymeleafReactiveModelAdditions:somedata
will result in a Model attribute calledsomedata
.Values of these execution attributes are allowed to be:
Publisher<?>
(includingFlux<?>
andMono<?>
).Supplier<? extends Publisher<?>>
: The supplier will be called atView
rendering time and the result will be added to the Model.Function<ServerWebExchange,? extends Publisher<?>>
: The function will be called atView
rendering time and the result will be added to the Model.
Value:
"ThymeleafReactiveModelAdditions:"
- Since:
- 3.0.10
- See Also:
- Constant Field Values
-
-
Method Detail
-
getMarkupSelector
public String getMarkupSelector()
-
setMarkupSelector
public void setMarkupSelector(String markupSelector)
-
setDefaultCharset
public void setDefaultCharset(Charset defaultCharset)
- Overrides:
setDefaultCharset
in classorg.springframework.web.reactive.result.view.AbstractView
-
setSupportedMediaTypes
public void setSupportedMediaTypes(List<org.springframework.http.MediaType> supportedMediaTypes)
- Overrides:
setSupportedMediaTypes
in classorg.springframework.web.reactive.result.view.AbstractView
-
getBeanName
public String getBeanName()
-
setBeanName
public void setBeanName(String beanName)
- Specified by:
setBeanName
in interfaceorg.springframework.beans.factory.BeanNameAware
-
getTemplateName
public String getTemplateName()
-
setTemplateName
public void setTemplateName(String templateName)
-
getLocale
protected Locale getLocale()
-
setLocale
protected void setLocale(Locale locale)
-
getResponseMaxChunkSizeBytes
public int getResponseMaxChunkSizeBytes()
-
setResponseMaxChunkSizeBytes
public void setResponseMaxChunkSizeBytes(int responseMaxBufferSizeBytes)
-
getTemplateEngine
protected ISpringWebFluxTemplateEngine getTemplateEngine()
-
setTemplateEngine
protected void setTemplateEngine(ISpringWebFluxTemplateEngine templateEngine)
-
render
public reactor.core.publisher.Mono<Void> render(Map<String,?> model, org.springframework.http.MediaType contentType, org.springframework.web.server.ServerWebExchange exchange)
- Specified by:
render
in interfaceorg.springframework.web.reactive.result.view.View
- Overrides:
render
in classorg.springframework.web.reactive.result.view.AbstractView
-
renderInternal
protected reactor.core.publisher.Mono<Void> renderInternal(Map<String,Object> renderAttributes, org.springframework.http.MediaType contentType, org.springframework.web.server.ServerWebExchange exchange)
- Specified by:
renderInternal
in classorg.springframework.web.reactive.result.view.AbstractView
-
-