public final class ModelFactory
extends java.lang.Object
Model before controller method
 invocation and with updates to it after the invocation.
 On initialization the model is populated with attributes temporarily stored
 in the session and through the invocation of @ModelAttribute methods.
 
On update model attributes are synchronized with the session and also
 BindingResult attributes are added if missing.
| Constructor and Description | 
|---|
| ModelFactory(java.util.List<InvocableHandlerMethod> handlerMethods,
            WebDataBinderFactory binderFactory,
            SessionAttributesHandler attributeHandler)Create a new instance with the given  @ModelAttributemethods. | 
| Modifier and Type | Method and Description | 
|---|---|
| static java.lang.String | getNameForParameter(MethodParameter parameter)Derive the model attribute name for the given method parameter based on
 a  @ModelAttributeparameter annotation (if present) or falling
 back on parameter type based conventions. | 
| static java.lang.String | getNameForReturnValue(java.lang.Object returnValue,
                     MethodParameter returnType)Derive the model attribute name for the given return value based on:
 
 the method  ModelAttributeannotation value
 the declared return type if it is more specific thanObjectthe actual return value type | 
| void | initModel(NativeWebRequest request,
         ModelAndViewContainer container,
         HandlerMethod handlerMethod)Populate the model in the following order:
 
 Retrieve "known" session attributes listed as  @SessionAttributes. | 
| void | updateModel(NativeWebRequest request,
           ModelAndViewContainer container)Promote model attributes listed as  @SessionAttributesto the session. | 
public ModelFactory(java.util.List<InvocableHandlerMethod> handlerMethods, WebDataBinderFactory binderFactory, SessionAttributesHandler attributeHandler)
@ModelAttribute methods.handlerMethods - the @ModelAttribute methods to invokebinderFactory - for preparation of BindingResult attributesattributeHandler - for access to session attributespublic void initModel(NativeWebRequest request, ModelAndViewContainer container, HandlerMethod handlerMethod) throws java.lang.Exception
@SessionAttributes.
 @ModelAttribute methods
 @ModelAttribute method arguments also listed as
 @SessionAttributes and ensure they're present in the model raising
 an exception if necessary.
 request - the current requestcontainer - a container with the model to be initializedhandlerMethod - the method for which the model is initializedjava.lang.Exception - may arise from @ModelAttribute methodspublic void updateModel(NativeWebRequest request, ModelAndViewContainer container) throws java.lang.Exception
@SessionAttributes to the session.
 Add BindingResult attributes where necessary.request - the current requestcontainer - contains the model to updatejava.lang.Exception - if creating BindingResult attributes failspublic static java.lang.String getNameForParameter(MethodParameter parameter)
@ModelAttribute parameter annotation (if present) or falling
 back on parameter type based conventions.parameter - a descriptor for the method parameterConventions.getVariableNameForParameter(MethodParameter)public static java.lang.String getNameForReturnValue(java.lang.Object returnValue,
                                                     MethodParameter returnType)
ModelAttribute annotation value
 Object
 returnValue - the value returned from a method invocationreturnType - a descriptor for the return type of the methodnull or empty String)