org.apache.myfaces.test.mock
Class MockFlash

java.lang.Object
  extended by javax.faces.context.Flash
      extended by org.apache.myfaces.test.mock.MockFlash
All Implemented Interfaces:
Map<String,Object>

public class MockFlash
extends javax.faces.context.Flash

Mock implementation of Flash.

$Id: MockFlash.java 1604204 2014-06-20 16:20:34Z lu4242 $

Since:
1.0.0

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected static String FLASH_CURRENT_MAP_CACHE
           
protected static String FLASH_CURRENT_MAP_KEY
           
protected static String FLASH_INSTANCE
          Key on app map to keep current instance
protected static String FLASH_KEEP_MESSAGES
          Key used to check if this request should keep messages (like tomahawk sandbox RedirectTracker.
protected static String FLASH_KEEP_MESSAGES_LIST
           
protected static String FLASH_POSTBACK_MAP_CACHE
           
protected static String FLASH_POSTBACK_MAP_KEY
           
protected static String FLASH_REDIRECT
          Key used to check if there is the current request will be or was redirected
protected static String FLASH_SCOPE_CACHE
          Session map prefix to flash maps
 
Constructor Summary
MockFlash()
           
 
Method Summary
protected  String _getNextToken()
           
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 void doPostPhaseActions(javax.faces.context.FacesContext facesContext)
           
 void doPrePhaseActions(javax.faces.context.FacesContext facesContext)
           
 Set<Map.Entry<String,Object>> entrySet()
           
 Object get(Object key)
           
static javax.faces.context.Flash getCurrentInstance(javax.faces.context.ExternalContext context)
          Return a Flash instance from the application map
protected  Map<String,Object> getCurrentRequestMap(javax.faces.context.FacesContext context)
          Return the flash map created on this traversal.
protected  Map<String,Object> getPostbackRequestMap(javax.faces.context.FacesContext context)
           
 boolean isEmpty()
           
 boolean isKeepMessages()
           
 boolean isRedirect()
          For check if there is a redirect we to take into accout this points:

1.

 void keep(String key)
          In few words take a value from request scope map and put it on current request map, so it is visible on the next request.
 Set<String> keySet()
           
 Object put(String key, Object value)
           
 void putAll(Map<? extends String,? extends Object> m)
           
 void putNow(String key, Object value)
          This is just an alias for request scope map.
 Object remove(Object key)
           
protected  void restoreMessages(javax.faces.context.FacesContext facesContext)
           
protected  void saveMessages(javax.faces.context.FacesContext facesContext)
           
 void setKeepMessages(boolean keepMessages)
          If this property is true, the messages should be keep for the next request, no matter if it is a normal postback case or a post-redirect-get case.
 void setRedirect(boolean redirect)
           
 int size()
           
 Collection<Object> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

FLASH_INSTANCE

protected static final String FLASH_INSTANCE
Key on app map to keep current instance


FLASH_REDIRECT

protected static final String FLASH_REDIRECT
Key used to check if there is the current request will be or was redirected


FLASH_KEEP_MESSAGES

protected static final String FLASH_KEEP_MESSAGES
Key used to check if this request should keep messages (like tomahawk sandbox RedirectTracker. Used when post-redirect-get pattern is used)


FLASH_KEEP_MESSAGES_LIST

protected static final String FLASH_KEEP_MESSAGES_LIST
See Also:
Constant Field Values

FLASH_SCOPE_CACHE

protected static final String FLASH_SCOPE_CACHE
Session map prefix to flash maps


FLASH_CURRENT_MAP_CACHE

protected static final String FLASH_CURRENT_MAP_CACHE

FLASH_CURRENT_MAP_KEY

protected static final String FLASH_CURRENT_MAP_KEY

FLASH_POSTBACK_MAP_CACHE

protected static final String FLASH_POSTBACK_MAP_CACHE

FLASH_POSTBACK_MAP_KEY

protected static final String FLASH_POSTBACK_MAP_KEY
Constructor Detail

MockFlash

public MockFlash()
Method Detail

_getNextToken

protected String _getNextToken()
Returns:
the next token to be assigned to this request

getCurrentInstance

public static javax.faces.context.Flash getCurrentInstance(javax.faces.context.ExternalContext context)
Return a Flash instance from the application map

Parameters:
context -
Returns:

getCurrentRequestMap

protected Map<String,Object> getCurrentRequestMap(javax.faces.context.FacesContext context)
Return the flash map created on this traversal. This one will be sent on next request, so it will be retrieved as postback map of the next request.

Note it is supposed that FLASH_CURRENT_MAP_KEY is initialized before restore view phase (see doPrePhaseActions() for details).

Parameters:
context -
Returns:

getPostbackRequestMap

protected Map<String,Object> getPostbackRequestMap(javax.faces.context.FacesContext context)

doPrePhaseActions

public void doPrePhaseActions(javax.faces.context.FacesContext facesContext)
Specified by:
doPrePhaseActions in class javax.faces.context.Flash

doPostPhaseActions

public void doPostPhaseActions(javax.faces.context.FacesContext facesContext)
Specified by:
doPostPhaseActions in class javax.faces.context.Flash

saveMessages

protected void saveMessages(javax.faces.context.FacesContext facesContext)

restoreMessages

protected void restoreMessages(javax.faces.context.FacesContext facesContext)

isRedirect

public boolean isRedirect()
For check if there is a redirect we to take into accout this points:

1. isRedirect() could be accessed many times during the same request. 2. According to Post-Redirect-Get pattern, we cannot ensure request scope values are preserved.

Specified by:
isRedirect in class javax.faces.context.Flash

setRedirect

public void setRedirect(boolean redirect)
Specified by:
setRedirect in class javax.faces.context.Flash

keep

public void keep(String key)
In few words take a value from request scope map and put it on current request map, so it is visible on the next request.

Specified by:
keep in class javax.faces.context.Flash

putNow

public void putNow(String key,
                   Object value)
This is just an alias for request scope map.

Specified by:
putNow in class javax.faces.context.Flash

isKeepMessages

public boolean isKeepMessages()
Specified by:
isKeepMessages in class javax.faces.context.Flash

setKeepMessages

public void setKeepMessages(boolean keepMessages)
If this property is true, the messages should be keep for the next request, no matter if it is a normal postback case or a post-redirect-get case.

Specified by:
setKeepMessages in class javax.faces.context.Flash

clear

public void clear()

containsKey

public boolean containsKey(Object key)

containsValue

public boolean containsValue(Object value)

entrySet

public Set<Map.Entry<String,Object>> entrySet()

get

public Object get(Object key)

isEmpty

public boolean isEmpty()

keySet

public Set<String> keySet()

put

public Object put(String key,
                  Object value)

putAll

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

remove

public Object remove(Object key)

size

public int size()

values

public Collection<Object> values()


Copyright © 2014 The Apache Software Foundation. All Rights Reserved.