Top Description Inners Fields Constructors Methods
org.springframework.web.reactive

public Class BindingContext

extends Object
Class Inheritance
Known Direct Subclasses
org.springframework.web.reactive.result.method.annotation.InitBinderBindingContext
Imports
java.lang.annotation.Annotation, java.util.Collection, .Collections, .Map, reactor.core.publisher.Mono, org.springframework.beans.BeanUtils, org.springframework.core.MethodParameter, .ReactiveAdapterRegistry, .ResolvableType, org.springframework.lang.Nullable, org.springframework.ui.Model, org.springframework.validation.BindingResult, .DataBinder, .SmartValidator, org.springframework.validation.support.BindingAwareConcurrentModel, org.springframework.web.bind.support.BindParamNameResolver, .WebBindingInitializer, .WebExchangeDataBinder, org.springframework.web.server.ServerErrorException, .ServerWebExchange

Context to assist with binding request data onto Objects and provide access to a shared Model with controller-specific attributes.

Provides methods to create a WebExchangeDataBinder for a specific target, command Object to apply data binding and validation to, or without a target Object for simple type conversion from request values.

Container for the default model for the request.

Authors
Rossen Stoyanchev, Juergen Hoeller
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
BindingContext.ExtendedWebExchangeDataBinder

Extended variant of WebExchangeDataBinder, adding path variables.

private static class
BindingContext.MethodValidationInitializer

Excludes Bean Validation if the method parameter has @Valid.

Field Summary

Modifier and TypeField and Description
private final WebBindingInitializer
private boolean
private final Model
private final ReactiveAdapterRegistry

Constructor Summary

AccessConstructor and Description
public
BindingContext()

Create an instance without an initializer.

public
BindingContext(WebBindingInitializer initializer)

Create an instance with the given initializer, which may be null.

public
BindingContext(WebBindingInitializer initializer, ReactiveAdapterRegistry registry)

Create an instance with the given initializer and ReactiveAdapterRegistry.

Method Summary

Modifier and TypeMethod and Description
public WebExchangeDataBinder

Returns:

the created data binder
createDataBinder
(ServerWebExchange
the current exchange
exchange
,
Object
the object to create a data binder for
target
,
String
the name of the target object
name
)

Create a binder with a target object.

public WebExchangeDataBinder

Returns:

the created data binder
createDataBinder
(ServerWebExchange
the current exchange
exchange
,
String
the name of the target object
name
)

Shortcut method to create a binder without a target object.

public WebExchangeDataBinder
createDataBinder(ServerWebExchange exchange, Object target, String name, ResolvableType targetType)

Create a binder with a target object and a targetType.

public Model
getModel()

Return the default model.

protected WebExchangeDataBinder
initDataBinder(WebExchangeDataBinder binder, ServerWebExchange exchange)

Initialize the data binder instance for the given exchange.

private boolean
public void
setMethodValidationApplicable(boolean methodValidationApplicable)

Configure flag to signal whether validation will be applied to handler method arguments, which is the case if Bean Validation is enabled in Spring MVC, and method parameters have @Constraint annotations.

public void
updateModel(ServerWebExchange
the current exchange
exchange
)

Invoked before rendering to add BindingResult attributes where necessary, and also to promote model attributes listed as @SessionAttributes to the session.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

initializerback to summary
private final WebBindingInitializer initializer
Annotations
@Nullable
methodValidationApplicableback to summary
private boolean methodValidationApplicable
modelback to summary
private final Model model
reactiveAdapterRegistryback to summary
private final ReactiveAdapterRegistry reactiveAdapterRegistry

Constructor Detail

BindingContextback to summary
public BindingContext()

Create an instance without an initializer.

BindingContextback to summary
public BindingContext(WebBindingInitializer initializer)

Create an instance with the given initializer, which may be null.

BindingContextback to summary
public BindingContext(WebBindingInitializer initializer, ReactiveAdapterRegistry registry)

Create an instance with the given initializer and ReactiveAdapterRegistry.

Since
6.1

Method Detail

createDataBinderback to summary
public WebExchangeDataBinder createDataBinder(ServerWebExchange exchange, Object target, String name)

Create a binder with a target object.

Parameters
exchange:ServerWebExchange

the current exchange

target:Object

the object to create a data binder for

name:String

the name of the target object

Returns:WebExchangeDataBinder

the created data binder

Exceptions
ServerErrorException:
if @InitBinder method invocation fails
createDataBinderback to summary
public WebExchangeDataBinder createDataBinder(ServerWebExchange exchange, String name)

Shortcut method to create a binder without a target object.

Parameters
exchange:ServerWebExchange

the current exchange

name:String

the name of the target object

Returns:WebExchangeDataBinder

the created data binder

Exceptions
ServerErrorException:
if @InitBinder method invocation fails
createDataBinderback to summary
public WebExchangeDataBinder createDataBinder(ServerWebExchange exchange, Object target, String name, ResolvableType targetType)

Create a binder with a target object and a targetType. If the target is null, then targetType is set.

Since
6.1
getModelback to summary
public Model getModel()

Return the default model.

initDataBinderback to summary
protected WebExchangeDataBinder initDataBinder(WebExchangeDataBinder binder, ServerWebExchange exchange)

Initialize the data binder instance for the given exchange.

Exceptions
ServerErrorException:
if @InitBinder method invocation fails
isBindingCandidateback to summary
private boolean isBindingCandidate(String name, Object value)
setMethodValidationApplicableback to summary
public void setMethodValidationApplicable(boolean methodValidationApplicable)

Configure flag to signal whether validation will be applied to handler method arguments, which is the case if Bean Validation is enabled in Spring MVC, and method parameters have @Constraint annotations.

Since
6.1
updateModelback to summary
public void updateModel(ServerWebExchange exchange)

Invoked before rendering to add BindingResult attributes where necessary, and also to promote model attributes listed as @SessionAttributes to the session.

Parameters
exchange:ServerWebExchange

the current exchange

Since
6.1
org.springframework.web.reactive back to summary

private Class BindingContext.ExtendedWebExchangeDataBinder

extends WebExchangeDataBinder
Class Inheritance

Extended variant of WebExchangeDataBinder, adding path variables.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Mono<Map<String, Object>>
getValuesToBind(ServerWebExchange
the current exchange
exchange
)

Overrides org.springframework.web.bind.support.WebExchangeDataBinder.getValuesToBind.

Obtain the values for data binding.

Inherited from org.springframework.web.bind.support.WebExchangeDataBinder:
addBindValuebindconstructextractValuesToBindshouldConstructArgument

Constructor Detail

ExtendedWebExchangeDataBinderback to summary
public ExtendedWebExchangeDataBinder(Object target, String objectName)

Method Detail

getValuesToBindback to summary
public Mono<Map<String, Object>> getValuesToBind(ServerWebExchange exchange)

Overrides org.springframework.web.bind.support.WebExchangeDataBinder.getValuesToBind.

Doc from org.springframework.web.bind.support.WebExchangeDataBinder.getValuesToBind.

Obtain the values for data binding. By default, this delegates to extractValuesToBind(ServerWebExchange).

Parameters
exchange:ServerWebExchange

the current exchange

Returns:Mono<Map<String, Object>>

a map of bind values

Annotations
@Override
org.springframework.web.reactive back to summary

private Class BindingContext.MethodValidationInitializer

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.web.reactive.BindingContext.MethodValidationInitializer

Excludes Bean Validation if the method parameter has @Valid.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MethodValidationInitializerback to summary
private MethodValidationInitializer()

Method Detail

initBinderback to summary
public static void initBinder(DataBinder binder, MethodParameter parameter)