Class BindingContext

java.lang.Object
org.springframework.web.reactive.BindingContext

public class BindingContext extends Object
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

    Constructors
    Constructor
    Description
    Create a new BindingContext.
    BindingContext(org.springframework.web.bind.support.WebBindingInitializer initializer)
    Create a new BindingContext with the given initializer.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.web.bind.support.WebExchangeDataBinder
    createDataBinder(org.springframework.web.server.ServerWebExchange exchange, Object target, String name)
    Create a WebExchangeDataBinder to apply data binding and validation with on the target, command object.
    org.springframework.web.bind.support.WebExchangeDataBinder
    createDataBinder(org.springframework.web.server.ServerWebExchange exchange, String name)
    Create a WebExchangeDataBinder without a target object for type conversion of request values to simple types.
    org.springframework.ui.Model
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BindingContext

      public BindingContext()
      Create a new BindingContext.
    • BindingContext

      public BindingContext(@Nullable org.springframework.web.bind.support.WebBindingInitializer initializer)
      Create a new BindingContext with the given initializer.
      Parameters:
      initializer - the binding initializer to apply (may be null)
  • Method Details

    • getModel

      public org.springframework.ui.Model getModel()
      Return the default model.
    • createDataBinder

      public org.springframework.web.bind.support.WebExchangeDataBinder createDataBinder(org.springframework.web.server.ServerWebExchange exchange, @Nullable Object target, String name)
      Create a WebExchangeDataBinder to apply data binding and validation with on the target, command object.
      Parameters:
      exchange - the current exchange
      target - the object to create a data binder for
      name - the name of the target object
      Returns:
      the created data binder
      Throws:
      org.springframework.web.server.ServerErrorException - if @InitBinder method invocation fails
    • 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
    • createDataBinder

      public org.springframework.web.bind.support.WebExchangeDataBinder createDataBinder(org.springframework.web.server.ServerWebExchange exchange, String name)
      Create a WebExchangeDataBinder without a target object for type conversion of request values to simple types.
      Parameters:
      exchange - the current exchange
      name - the name of the target object
      Returns:
      the created data binder
      Throws:
      org.springframework.web.server.ServerErrorException - if @InitBinder method invocation fails