|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.method.support.ModelAndViewContainer
public class ModelAndViewContainer
Records model and view related decisions made by
HandlerMethodArgumentResolver
s and
HandlerMethodReturnValueHandler
s during the course of invocation of
a controller method.
The setRequestHandled(boolean)
flag can be used to indicate the request
has been handled directly and view resolution is not required.
A default Model
is automatically created at instantiation.
An alternate model instance may be provided via setRedirectModel(org.springframework.ui.ModelMap)
for use in a redirect scenario. When setRedirectModelScenario(boolean)
is set
to true
signalling a redirect scenario, the getModel()
returns the redirect model instead of the default model.
Constructor Summary | |
---|---|
ModelAndViewContainer()
Create a new instance. |
Method Summary | |
---|---|
ModelAndViewContainer |
addAllAttributes(Map<String,?> attributes)
Copy all attributes to the underlying model. |
ModelAndViewContainer |
addAttribute(Object value)
Add the supplied attribute to the underlying model. |
ModelAndViewContainer |
addAttribute(String name,
Object value)
Add the supplied attribute to the underlying model. |
boolean |
containsAttribute(String name)
Whether the underlying model contains the given attribute name. |
ModelMap |
getModel()
Return the model to use: the "default" or the "redirect" model. |
SessionStatus |
getSessionStatus()
Return the SessionStatus instance to use that can be used to
signal that session processing is complete. |
Object |
getView()
Return the View object, or null if we using a view name
to be resolved by the DispatcherServlet via a ViewResolver. |
String |
getViewName()
Return the view name to be resolved by the DispatcherServlet via a ViewResolver, or null if a View object is set. |
boolean |
isRequestHandled()
Whether the request is handled directly. |
boolean |
isViewReference()
Whether the view is a view reference specified via a name to be resolved by the DispatcherServlet via a ViewResolver. |
ModelAndViewContainer |
mergeAttributes(Map<String,?> attributes)
Copy attributes in the supplied Map with existing objects of
the same name taking precedence (i.e. |
void |
setIgnoreDefaultModelOnRedirect(boolean ignoreDefaultModelOnRedirect)
When set to true the default model is never used in a redirect
scenario. |
void |
setRedirectModel(ModelMap redirectModel)
Provide a separate model instance to use in a redirect scenario. |
void |
setRedirectModelScenario(boolean redirectModelScenario)
Signal the conditions are in place for using a redirect model. |
void |
setRequestHandled(boolean requestHandled)
Signal a scenario where the request is handled directly. |
void |
setView(Object view)
Set a View object to be used by the DispatcherServlet. |
void |
setViewName(String viewName)
Set a view name to be resolved by the DispatcherServlet via a ViewResolver. |
String |
toString()
Return diagnostic information. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ModelAndViewContainer()
Method Detail |
---|
public void setViewName(String viewName)
public String getViewName()
null
if a View object is set.
public void setView(Object view)
public Object getView()
null
if we using a view name
to be resolved by the DispatcherServlet via a ViewResolver.
public boolean isViewReference()
public void setRequestHandled(boolean requestHandled)
A HandlerMethodReturnValueHandler
may use this flag to
indicate the response has been fully handled and view resolution
is not required (e.g. @ResponseBody
).
A HandlerMethodArgumentResolver
may also use this flag
to indicate the presence of an argument (e.g.
ServletResponse
or OutputStream
) that may lead to
a complete response depending on the method return value.
The default value is true
.
public boolean isRequestHandled()
public ModelMap getModel()
The default model is used if "redirectModelScenario=false"
or
if the redirect model is null
(i.e. it wasn't declared as a
method argument) and ignoreDefaultModelOnRedirect=false
.
public void setRedirectModel(ModelMap redirectModel)
setRedirectModelScenario(boolean)
gets set to true
to signal
a redirect scenario.
public void setRedirectModelScenario(boolean redirectModelScenario)
public void setIgnoreDefaultModelOnRedirect(boolean ignoreDefaultModelOnRedirect)
true
the default model is never used in a redirect
scenario. So if a redirect model is not available, an empty model is
used instead.
When set to false
the default model can be used in a redirect
scenario if a redirect model is not available.
The default setting is false
.
public SessionStatus getSessionStatus()
SessionStatus
instance to use that can be used to
signal that session processing is complete.
public ModelAndViewContainer addAttribute(String name, Object value)
ModelMap.addAttribute(String, Object)
public ModelAndViewContainer addAttribute(Object value)
Model.addAttribute(Object)
public ModelAndViewContainer addAllAttributes(Map<String,?> attributes)
ModelMap.addAllAttributes(Map)
public ModelAndViewContainer mergeAttributes(Map<String,?> attributes)
Map
with existing objects of
the same name taking precedence (i.e. not getting replaced).
ModelMap.mergeAttributes(Map)
public boolean containsAttribute(String name)
ModelMap.containsAttribute(String)
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |