程序包 cn.taketoday.web
类 BindingContext
java.lang.Object
cn.taketoday.web.BindingContext
- 直接已知子类:
InitBinderBindingContext
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 WebDataBinder 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.
- 从以下版本开始:
- 4.0 2022/4/8 23:40
- 作者:
- Rossen Stoyanchev, Juergen Hoeller, Harry Yang
-
字段概要
字段修饰符和类型字段说明private final WebBindingInitializerprivate cn.taketoday.ui.ModelMapprotected ModelAndViewprivate RedirectModelprivate SessionStatus -
构造器概要
构造器构造器说明Create a newBindingContext.BindingContext(WebBindingInitializer initializer) Create a newBindingContextwith the given initializer. -
方法概要
修饰符和类型方法说明addAllAttributes(Map<String, ?> attributes) Copy all attributes to the underlying model.addAttribute(Object value) Add the supplied attribute to the underlying model.addAttribute(String name, Object value) Add the supplied attribute to the underlying model.booleancontainsAttribute(String name) Whether the underlying model contains the given attribute name.createBinder(RequestContext request, Object target, String objectName) Create aWebDataBinderto apply data binding and validation with on the target, command object.createBinder(RequestContext request, Object target, String objectName, cn.taketoday.core.ResolvableType targetType) Variant ofcreateBinder(RequestContext, Object, String)with aResolvableTypefor which theDataBinderis created.createBinder(RequestContext context, String objectName) Create aWebDataBinderwithout a target object for type conversion of request values to simple types.protected WebDataBindercreateBinderInstance(Object target, String objectName, RequestContext request) Extension point to create the WebDataBinder instance.cn.taketoday.ui.ModelMapgetModel()Return the default model.Get aModelAndViewReturn theSessionStatusinstance to use that can be used to signal that session processing is complete.booleanhasModel()booleanvoidinitBinder(WebDataBinder dataBinder, RequestContext request) Initialize the data binder instance for the given exchange.voidinitModel(RequestContext request) Populate the model in the following order: Retrieve "known" session attributes listed as@SessionAttributes.booleanisBindingDisabled(String name) Whether binding is disabled for the given model attribute.booleanReturn whether the current handler's session processing has been marked as complete.mergeAttributes(Map<String, ?> attributes) Copy attributes in the suppliedMapwith existing objects of the same name taking precedence (i.e. not getting replaced).removeAttributes(Map<String, ?> attributes) Remove the given attributes from the model.voidsetBinding(String attributeName, boolean enabled) Register whether data binding should occur for a corresponding model attribute, corresponding to an@ModelAttribute(binding=true/false)declaration.voidsetBindingDisabled(String attributeName) Programmatically register an attribute for which data binding should not occur, not even for a subsequent@ModelAttributedeclaration.voidsetRedirectModel(RedirectModel redirectModel) toString()Return diagnostic information.voidupdateModel(RequestContext request) Promote model attributes listed as@SessionAttributesto the session.
-
字段详细资料
-
model
private cn.taketoday.ui.ModelMap model -
redirectModel
-
noBinding
-
bindingDisabled
-
sessionStatus
-
initializer
-
modelAndView
-
-
构造器详细资料
-
BindingContext
public BindingContext()Create a newBindingContext. -
BindingContext
Create a newBindingContextwith the given initializer.- 参数:
initializer- the binding initializer to apply (may benull)
-
-
方法详细资料
-
createBinder
Create aWebDataBinderwithout a target object for type conversion of request values to simple types.- 参数:
context- the current exchangeobjectName- the name of the target object- 返回:
- the created data binder
- 抛出:
Throwable- if@InitBindermethod invocation fails
-
createBinder
public WebDataBinder createBinder(RequestContext request, @Nullable Object target, String objectName) throws Throwable Create aWebDataBinderto apply data binding and validation with on the target, command object.- 参数:
request- the current requesttarget- the object to create a data binder forobjectName- the name of the target object- 返回:
- the created data binder
- 抛出:
Throwable- if@InitBindermethod invocation fails
-
createBinder
public WebDataBinder createBinder(RequestContext request, @Nullable Object target, String objectName, @Nullable cn.taketoday.core.ResolvableType targetType) throws Throwable Variant ofcreateBinder(RequestContext, Object, String)with aResolvableTypefor which theDataBinderis created. This may be used to construct the target, or otherwise provide more insight on how to initialize the binder.- 抛出:
Throwable
-
createBinderInstance
protected WebDataBinder createBinderInstance(@Nullable Object target, String objectName, RequestContext request) throws Exception Extension point to create the WebDataBinder instance. By default this isWebDataBinder.- 参数:
target- the binding target ornullfor type conversion onlyobjectName- the binding target object namerequest- the current request- 抛出:
Exception- in case of invalid state or arguments
-
initBinder
Initialize the data binder instance for the given exchange.- 抛出:
Throwable- if@InitBindermethod invocation fails
-
getModelAndView
Get aModelAndViewIf there isn't a
ModelAndViewin thisRequestContext, Create One- 返回:
- Returns
ModelAndView
-
hasModelAndView
public boolean hasModelAndView()- 从以下版本开始:
- 3.0
-
hasModel
public boolean hasModel()- 从以下版本开始:
- 4.0
-
getModel
public cn.taketoday.ui.ModelMap getModel()Return the default model. -
updateModel
Promote model attributes listed as@SessionAttributesto the session. AddBindingResultattributes where necessary.- 参数:
request- the current request- 抛出:
Throwable- if creating BindingResult attributes fails
-
initModel
Populate the model in the following order:- Retrieve "known" session attributes listed as
@SessionAttributes. - Invoke
@ModelAttributemethods - Find
@ModelAttributemethod arguments also listed as@SessionAttributesand ensure they're present in the model raising an exception if necessary.
- 参数:
request- the current request- 抛出:
Throwable- may arise from@ModelAttributemethods
- Retrieve "known" session attributes listed as
-
getRedirectModel
-
setRedirectModel
-
setBindingDisabled
Programmatically register an attribute for which data binding should not occur, not even for a subsequent@ModelAttributedeclaration.- 参数:
attributeName- the name of the attribute
-
isBindingDisabled
Whether binding is disabled for the given model attribute. -
setBinding
Register whether data binding should occur for a corresponding model attribute, corresponding to an@ModelAttribute(binding=true/false)declaration.Note: While this flag will be taken into account by
isBindingDisabled(java.lang.String), a hardsetBindingDisabled(java.lang.String)declaration will always override it.- 参数:
attributeName- the name of the attribute
-
getSessionStatus
Return theSessionStatusinstance to use that can be used to signal that session processing is complete. -
isSessionComplete
public boolean isSessionComplete()Return whether the current handler's session processing has been marked as complete. -
addAttribute
Add the supplied attribute to the underlying model. A shortcut forgetModel().addAttribute(String, Object). -
addAttribute
Add the supplied attribute to the underlying model. A shortcut forgetModel().addAttribute(Object). -
addAllAttributes
Copy all attributes to the underlying model. A shortcut forgetModel().addAllAttributes(Map). -
mergeAttributes
Copy attributes in the suppliedMapwith existing objects of the same name taking precedence (i.e. not getting replaced). A shortcut forgetModel().mergeAttributes(Map<String, ?>). -
removeAttributes
Remove the given attributes from the model. -
containsAttribute
Whether the underlying model contains the given attribute name. A shortcut forgetModel().containsAttribute(String). -
toString
Return diagnostic information.
-