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

## org.springframework.web.servlet.mvc.support
Class RedirectAttributesModelMap

    java.lang.Object
      java.util.AbstractMap<K,V>
          java.util.HashMap<K,V>
              java.util.LinkedHashMap<String,Object>
                  org.springframework.ui.ModelMap
                      org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap

All Implemented Interfaces:
  Serializable, Cloneable, Map<String,Object>, Model, RedirectAttributes

    public class RedirectAttributesModelMap

extends ModelMap
implements RedirectAttributes

A `ModelMap` implementation of `RedirectAttributes` that formats values as Strings using a `DataBinder`. Also provides a place to store flash attributes so they can survive a redirect without the need to be embedded in the redirect URL.

Since:
  3.1
Author:
  Rossen Stoyanchev
See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class java.util.AbstractMap
`AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>`

Constructor Summary
`RedirectAttributesModelMap()` Default constructor without a DataBinder.
`RedirectAttributesModelMap(DataBinder dataBinder)` Class constructor.

Method Summary
`RedirectAttributesModelMap` | `addAllAttributes(Collection<?> attributeValues)` Copy all attributes in the supplied `Collection` into this `Map`, using attribute name generation for each element.
`RedirectAttributesModelMap` | `addAllAttributes(Map<String,?> attributes)` Copy all attributes in the supplied `Map` into this `Map`.
`RedirectAttributesModelMap` | `addAttribute(Object attributeValue)` Add the supplied attribute to this `Map` using a `generated name`.
`RedirectAttributesModelMap` | `addAttribute(String attributeName, Object attributeValue)` Add the supplied attribute under the supplied name.
`RedirectAttributes` | `addFlashAttribute(Object attributeValue)` Add the given flash storage using a `generated name`.
`RedirectAttributes` | `addFlashAttribute(String attributeName, Object attributeValue)` Add the given flash attribute.
`Map<String,Object>` | `asMap()` Return the current set of model attributes as a Map.
`Map<String,?>` | `getFlashAttributes()` Return the attributes candidate for flash storage or an empty Map.
`RedirectAttributesModelMap` | `mergeAttributes(Map<String,?> attributes)` Copy all attributes in the supplied `Map` into this `Map`, with existing objects of the same name taking precedence (i.e.
`Object` | `put(String key, Object value)`
`void` | `putAll(Map<? extends String,? extends Object> map)`

Methods inherited from class org.springframework.ui.ModelMap
`addAllObjects, addAllObjects, addObject, addObject, containsAttribute`

Methods inherited from class java.util.LinkedHashMap
`clear, containsValue, get, removeEldestEntry`

Methods inherited from class java.util.HashMap
`clone, containsKey, entrySet, isEmpty, keySet, 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 org.springframework.ui.Model
`containsAttribute`

Methods inherited from interface java.util.Map
`containsKey, entrySet, equals, hashCode, isEmpty, keySet, remove, size, values`

Constructor Detail

### RedirectAttributesModelMap

    public RedirectAttributesModelMap(DataBinder dataBinder)

  Class constructor.

  Parameters:
    `dataBinder` - used to format attribute values as Strings.

### RedirectAttributesModelMap

    public RedirectAttributesModelMap()

  Default constructor without a DataBinder. Attribute values are converted to String via `AbstractMap.toString()`.

Method Detail

### getFlashAttributes

    public Map<String,?> getFlashAttributes()

  Return the attributes candidate for flash storage or an empty Map.

  Specified by:
    `getFlashAttributes` in interface `RedirectAttributes`

### addAttribute

    public RedirectAttributesModelMap addAttribute(String attributeName,
                                                   Object attributeValue)

  Add the supplied attribute under the supplied name.

  Formats the attribute value as a String before adding it.

  Specified by:
    `addAttribute` in interface `Model`
  Specified by:
    `addAttribute` in interface `RedirectAttributes`
  Overrides:
    `addAttribute` in class `ModelMap`
  Parameters:
    `attributeName` - the name of the model attribute (never `null`)
    `attributeValue` - the model attribute value (can be `null`)

### addAttribute

    public RedirectAttributesModelMap addAttribute(Object attributeValue)

  Add the supplied attribute to this `Map` using 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.

  Formats the attribute value as a String before adding it.

  Specified by:
    `addAttribute` in interface `Model`
  Specified by:
    `addAttribute` in interface `RedirectAttributes`
  Overrides:
    `addAttribute` in class `ModelMap`
  Parameters:
    `attributeValue` - the model attribute value (never `null`)

### addAllAttributes

    public RedirectAttributesModelMap addAllAttributes(Collection<?> attributeValues)

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

  Each attribute value is formatted as a String before being added.

  Specified by:
    `addAllAttributes` in interface `Model`
  Specified by:
    `addAllAttributes` in interface `RedirectAttributes`
  Overrides:
    `addAllAttributes` in class `ModelMap`
  See Also:
    `ModelMap.addAttribute(Object)`

### addAllAttributes

    public RedirectAttributesModelMap addAllAttributes(Map<String,?> attributes)

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

  Each attribute value is formatted as a String before being added.

  Specified by:
    `addAllAttributes` in interface `Model`
  Overrides:
    `addAllAttributes` in class `ModelMap`
  See Also:
    `ModelMap.addAttribute(String, Object)`

### mergeAttributes

    public RedirectAttributesModelMap mergeAttributes(Map<String,?> 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).

  Each attribute value is formatted as a String before being merged.

  Specified by:
    `mergeAttributes` in interface `Model`
  Specified by:
    `mergeAttributes` in interface `RedirectAttributes`
  Overrides:
    `mergeAttributes` in class `ModelMap`

### asMap

    public Map<String,Object> asMap()

  Description copied from interface: `Model`
  Return the current set of model attributes as a Map.

  Specified by:
    `asMap` in interface `Model`

### put

    public Object put(String key,
                      Object value)

  The value is formatted as a String before being added.

  Specified by:
    `put` in interface `Map<String,Object>`
  Overrides:
    `put` in class `HashMap<String,Object>`

### putAll

    public void putAll(Map<? extends String,? extends Object> map)

  Each value is formatted as a String before being added.

  Specified by:
    `putAll` in interface `Map<String,Object>`
  Overrides:
    `putAll` in class `HashMap<String,Object>`

### addFlashAttribute

    public RedirectAttributes addFlashAttribute(String attributeName,
                                                Object attributeValue)

  Description copied from interface: `RedirectAttributes`
  Add the given flash attribute.

  Specified by:
    `addFlashAttribute` in interface `RedirectAttributes`
  Parameters:
    `attributeName` - the attribute name; never `null`
    `attributeValue` - the attribute value; may be `null`

### addFlashAttribute

    public RedirectAttributes addFlashAttribute(Object attributeValue)

  Description copied from interface: `RedirectAttributes`
  Add the given flash storage using a `generated name`.

  Specified by:
    `addFlashAttribute` in interface `RedirectAttributes`
  Parameters:
    `attributeValue` - the flash attribute value; never `null`

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