|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap<K,V> java.util.HashMap<K,V> java.util.LinkedHashMap org.springframework.ui.ModelMap
public class ModelMap
Implementation of Map
for use when building model data for use
with UI tools. Supports chained calls and generation of model attribute names.
This class serves as generic model holder for both Servlet and Portlet MVC,
but is not tied to either of those. Check out the Model
interface for
a Java-5-based interface variant that serves the same purpose.
Conventions.getVariableName(java.lang.Object)
,
ModelAndView
,
ModelAndView
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
Constructor Summary | |
---|---|
ModelMap()
Construct a new, empty ModelMap . |
|
ModelMap(Object attributeValue)
Construct a new ModelMap containing the supplied attribute. |
|
ModelMap(String attributeName,
Object attributeValue)
Construct a new ModelMap containing the supplied attribute
under the supplied name. |
Method Summary | |
---|---|
ModelMap |
addAllAttributes(Collection attributeValues)
Copy all attributes in the supplied Collection into this
Map , using attribute name generation for each element. |
ModelMap |
addAllAttributes(Map attributes)
Copy all attributes in the supplied Map into this Map . |
ModelMap |
addAllObjects(Collection objects)
Deprecated. as of Spring 2.5, in favor of addAllAttributes(Collection) |
ModelMap |
addAllObjects(Map objects)
Deprecated. as of Spring 2.5, in favor of addAllAttributes(Map) |
ModelMap |
addAttribute(Object attributeValue)
Add the supplied attribute to this Map using a
generated name . |
ModelMap |
addAttribute(String attributeName,
Object attributeValue)
Add the supplied attribute under the supplied name. |
ModelMap |
addObject(Object modelObject)
Deprecated. as of Spring 2.5, in favor of addAttribute(Object) |
ModelMap |
addObject(String modelName,
Object modelObject)
Deprecated. as of Spring 2.5, in favor of addAttribute(String, Object) |
boolean |
containsAttribute(String attributeName)
Does this model contain an attribute of the given name? |
ModelMap |
mergeAttributes(Map attributes)
Copy all attributes in the supplied Map into this Map ,
with existing objects of the same name taking precedence (i.e. not getting
replaced). |
Methods inherited from class java.util.LinkedHashMap |
---|
clear, containsValue, get, removeEldestEntry |
Methods inherited from class java.util.HashMap |
---|
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Constructor Detail |
---|
public ModelMap()
ModelMap
.
public ModelMap(String attributeName, Object attributeValue)
ModelMap
containing the supplied attribute
under the supplied name.
addAttribute(String, Object)
public ModelMap(Object attributeValue)
ModelMap
containing the supplied attribute.
Uses attribute name generation to generate the key for the supplied model
object.
addAttribute(Object)
Method Detail |
---|
public ModelMap addAttribute(String attributeName, Object attributeValue)
attributeName
- the name of the model attribute (never null
)attributeValue
- the model attribute value (can be null
)public ModelMap addAttribute(Object attributeValue)
Map
using a
generated name
.
Collections
are not added to
the model when using this method because we cannot correctly determine
the true convention name. View code should check for null
rather
than for empty collections as is already done by JSTL tags.
attributeValue
- the model attribute value (never null
)public ModelMap addAllAttributes(Collection attributeValues)
Collection
into this
Map
, using attribute name generation for each element.
addAttribute(Object)
public ModelMap addAllAttributes(Map attributes)
Map
into this Map
.
addAttribute(String, Object)
public ModelMap mergeAttributes(Map attributes)
Map
into this Map
,
with existing objects of the same name taking precedence (i.e. not getting
replaced).
public boolean containsAttribute(String attributeName)
attributeName
- the name of the model attribute (never null
)
public ModelMap addObject(String modelName, Object modelObject)
addAttribute(String, Object)
public ModelMap addObject(Object modelObject)
addAttribute(Object)
public ModelMap addAllObjects(Collection objects)
addAllAttributes(Collection)
public ModelMap addAllObjects(Map objects)
addAllAttributes(Map)
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |