Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.ui
Class ModelMap

    java.lang.Object
      java.util.AbstractMap<K,V>
          java.util.HashMap
              org.springframework.ui.ModelMap

All Implemented Interfaces:
  Serializable, Cloneable, Map

    public class ModelMap

extends HashMap

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.

Since:
  2.0
Author:
  Rob Harrop
See Also:
  `Conventions.getVariableName(java.lang.Object)`, `ModelAndView`, `ModelAndView`, Serialized Form

Constructor Summary
`ModelMap()` Construct a new, empty `ModelMap`.
`ModelMap(Object modelObject)` Construct a new `ModelMap` containing the supplied model object.
`ModelMap(String modelName, Object modelObject)` Construct a new `ModelMap` containing the supplied model object under the supplied name.

Method Summary
`ModelMap` | `addAllObjects(Collection objects)` Copy all objects in the supplied `Collection` into this `Map`, using attribute name generation for each element.
`ModelMap` | `addAllObjects(Map objects)` Copy all objects in the supplied `Map` into this `Map`.
`ModelMap` | `addObject(Object modelObject)` Add the supplied `Object` to this `Map` used a `generated name`.
`ModelMap` | `addObject(String modelName, Object modelObject)` Add the supplied `Object` under the supplied name.

Methods inherited from class java.util.HashMap
`clear, clone, containsKey, containsValue, entrySet, get, 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
`equals, hashCode`

Constructor Detail

### ModelMap

    public ModelMap()

  Construct a new, empty `ModelMap`.

### ModelMap

    public ModelMap(String modelName,
                    Object modelObject)

  Construct a new `ModelMap` containing the supplied model object under the supplied name.

  See Also:
    `addObject(String, Object)`

### ModelMap

    public ModelMap(Object modelObject)

  Construct a new `ModelMap` containing the supplied model object. Uses attribute name generation to generate the key for the supplied model object.

  See Also:
    `addObject(Object)`

Method Detail

### addObject

    public ModelMap addObject(String modelName,
                              Object modelObject)

  Add the supplied `Object` under the supplied name.

  Parameters:
    `modelName` - the name of the model attribute (never `null`)
    `modelObject` - the model attribute object (can be `null`)

### addObject

    public ModelMap addObject(Object modelObject)

  Add the supplied `Object` to this `Map` used a `generated name`.

  Note: Empty `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.

  Parameters:
    `modelObject` - the model attribute object (never `null`)

### addAllObjects

    public ModelMap addAllObjects(Map objects)

  Copy all objects in the supplied `Map` into this `Map`.

### addAllObjects

    public ModelMap addAllObjects(Collection objects)

  Copy all objects in the supplied `Collection` into this `Map`, using attribute name generation for each element.

  See Also:
    `addObject(Object)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2007 The Spring Framework.