Package org.springframework.web.reactive
Class BindingContext
java.lang.Object
org.springframework.web.reactive.BindingContext
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.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller
-
Constructor Summary
ConstructorDescriptionCreate an instance without an initializer.BindingContext
(org.springframework.web.bind.support.WebBindingInitializer initializer) Create an instance with the given initializer, which may benull
.BindingContext
(org.springframework.web.bind.support.WebBindingInitializer initializer, org.springframework.core.ReactiveAdapterRegistry registry) Create an instance with the given initializer andReactiveAdapterRegistry
. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.web.bind.support.WebExchangeDataBinder
createDataBinder
(org.springframework.web.server.ServerWebExchange exchange, Object target, String name) Create a binder with a target object.org.springframework.web.bind.support.WebExchangeDataBinder
createDataBinder
(org.springframework.web.server.ServerWebExchange exchange, Object target, String name, org.springframework.core.ResolvableType targetType) Create a binder with a target object and atargetType
.org.springframework.web.bind.support.WebExchangeDataBinder
createDataBinder
(org.springframework.web.server.ServerWebExchange exchange, String name) Shortcut method to create a binder without a target object.org.springframework.ui.Model
getModel()
Return the default model.protected org.springframework.web.bind.support.WebExchangeDataBinder
initDataBinder
(org.springframework.web.bind.support.WebExchangeDataBinder binder, org.springframework.web.server.ServerWebExchange exchange) Initialize the data binder instance for the given exchange.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.void
updateModel
(org.springframework.web.server.ServerWebExchange exchange) Invoked before rendering to addBindingResult
attributes where necessary, and also to promote model attributes listed as@SessionAttributes
to the session.
-
Constructor Details
-
BindingContext
public BindingContext()Create an instance without an initializer. -
BindingContext
public BindingContext(@Nullable org.springframework.web.bind.support.WebBindingInitializer initializer) Create an instance with the given initializer, which may benull
. -
BindingContext
public BindingContext(@Nullable org.springframework.web.bind.support.WebBindingInitializer initializer, org.springframework.core.ReactiveAdapterRegistry registry) Create an instance with the given initializer andReactiveAdapterRegistry
.- Since:
- 6.1
-
-
Method Details
-
getModel
public org.springframework.ui.Model getModel()Return the default model. -
setMethodValidationApplicable
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
-
createDataBinder
public org.springframework.web.bind.support.WebExchangeDataBinder createDataBinder(org.springframework.web.server.ServerWebExchange exchange, @Nullable Object target, String name) Create a binder with a target object.- Parameters:
exchange
- the current exchangetarget
- the object to create a data binder forname
- the name of the target object- Returns:
- the created data binder
- Throws:
org.springframework.web.server.ServerErrorException
- if@InitBinder
method invocation fails
-
createDataBinder
public org.springframework.web.bind.support.WebExchangeDataBinder createDataBinder(org.springframework.web.server.ServerWebExchange exchange, String name) Shortcut method to create a binder without a target object.- Parameters:
exchange
- the current exchangename
- the name of the target object- Returns:
- the created data binder
- Throws:
org.springframework.web.server.ServerErrorException
- if@InitBinder
method invocation fails
-
createDataBinder
public org.springframework.web.bind.support.WebExchangeDataBinder createDataBinder(org.springframework.web.server.ServerWebExchange exchange, @Nullable Object target, String name, @Nullable org.springframework.core.ResolvableType targetType) Create a binder with a target object and atargetType
. If the target isnull
, thentargetType
is set.- Since:
- 6.1
-
initDataBinder
protected org.springframework.web.bind.support.WebExchangeDataBinder initDataBinder(org.springframework.web.bind.support.WebExchangeDataBinder binder, org.springframework.web.server.ServerWebExchange exchange) Initialize the data binder instance for the given exchange.- Throws:
org.springframework.web.server.ServerErrorException
- if@InitBinder
method invocation fails
-
updateModel
public void updateModel(org.springframework.web.server.ServerWebExchange exchange) Invoked before rendering to addBindingResult
attributes where necessary, and also to promote model attributes listed as@SessionAttributes
to the session.- Parameters:
exchange
- the current exchange- Since:
- 6.1
-