spring-webmvc

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

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<java.lang.String,java.lang.Object>
              extended by org.springframework.ui.ModelMap
                  extended by org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>, org.springframework.ui.Model, RedirectAttributes

public class RedirectAttributesModelMap
extends org.springframework.ui.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
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
RedirectAttributesModelMap()
          Default constructor without a DataBinder.
RedirectAttributesModelMap(org.springframework.validation.DataBinder dataBinder)
          Class constructor.
 
Method Summary
 RedirectAttributesModelMap addAllAttributes(java.util.Collection<?> attributeValues)
          
 RedirectAttributesModelMap addAllAttributes(java.util.Map<java.lang.String,?> attributes)
          
 RedirectAttributesModelMap addAttribute(java.lang.Object attributeValue)
          
 RedirectAttributesModelMap addAttribute(java.lang.String attributeName, java.lang.Object attributeValue)
          
 RedirectAttributes addFlashAttribute(java.lang.Object attributeValue)
          Add the given flash storage using a generated name.
 RedirectAttributes addFlashAttribute(java.lang.String attributeName, java.lang.Object attributeValue)
          Add the given flash attribute.
 java.util.Map<java.lang.String,java.lang.Object> asMap()
           
 java.util.Map<java.lang.String,?> getFlashAttributes()
          Return the attributes candidate for flash storage or an empty Map.
 RedirectAttributesModelMap mergeAttributes(java.util.Map<java.lang.String,?> attributes)
          
 java.lang.Object put(java.lang.String key, java.lang.Object value)
          
 void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.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(org.springframework.validation.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 java.util.Map<java.lang.String,?> getFlashAttributes()
Return the attributes candidate for flash storage or an empty Map.

Specified by:
getFlashAttributes in interface RedirectAttributes

addAttribute

public RedirectAttributesModelMap addAttribute(java.lang.String attributeName,
                                               java.lang.Object attributeValue)

Formats the attribute value as a String before adding it.

Specified by:
addAttribute in interface org.springframework.ui.Model
Specified by:
addAttribute in interface RedirectAttributes
Overrides:
addAttribute in class org.springframework.ui.ModelMap

addAttribute

public RedirectAttributesModelMap addAttribute(java.lang.Object attributeValue)

Formats the attribute value as a String before adding it.

Specified by:
addAttribute in interface org.springframework.ui.Model
Specified by:
addAttribute in interface RedirectAttributes
Overrides:
addAttribute in class org.springframework.ui.ModelMap

addAllAttributes

public RedirectAttributesModelMap addAllAttributes(java.util.Collection<?> attributeValues)

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

Specified by:
addAllAttributes in interface org.springframework.ui.Model
Specified by:
addAllAttributes in interface RedirectAttributes
Overrides:
addAllAttributes in class org.springframework.ui.ModelMap

addAllAttributes

public RedirectAttributesModelMap addAllAttributes(java.util.Map<java.lang.String,?> attributes)

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

Specified by:
addAllAttributes in interface org.springframework.ui.Model
Overrides:
addAllAttributes in class org.springframework.ui.ModelMap

mergeAttributes

public RedirectAttributesModelMap mergeAttributes(java.util.Map<java.lang.String,?> attributes)

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

Specified by:
mergeAttributes in interface org.springframework.ui.Model
Specified by:
mergeAttributes in interface RedirectAttributes
Overrides:
mergeAttributes in class org.springframework.ui.ModelMap

asMap

public java.util.Map<java.lang.String,java.lang.Object> asMap()
Specified by:
asMap in interface org.springframework.ui.Model

put

public java.lang.Object put(java.lang.String key,
                            java.lang.Object value)

The value is formatted as a String before being added.

Specified by:
put in interface java.util.Map<java.lang.String,java.lang.Object>
Overrides:
put in class java.util.HashMap<java.lang.String,java.lang.Object>

putAll

public void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map)

Each value is formatted as a String before being added.

Specified by:
putAll in interface java.util.Map<java.lang.String,java.lang.Object>
Overrides:
putAll in class java.util.HashMap<java.lang.String,java.lang.Object>

addFlashAttribute

public RedirectAttributes addFlashAttribute(java.lang.String attributeName,
                                            java.lang.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(java.lang.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

spring-webmvc