Package ninja.session
Interface FlashScope
- 
- All Known Implementing Classes:
- FlashScopeImpl
 
 public interface FlashScopeFlash Scope consists of two kinds of data: "current" and "outgoing". Current data will only exist for the current request. Outgoing data will exist for the current and next request. Neither should be considered secure or encrypted. Its useful for communicating error messages or form submission results. A FlashScope is i18n aware and the values will be looked up for i18n translations by template engines that support it. If the Flash Scope has outgoing data then a cookie will be sent to the client and will be valid on the next request. Stuff in a flash cookie gets deleted after the next request. If an incoming request has a flash cookie then the data from it will be loaded as "current" flash data. Unless you keep() those keys that data will only be valid for the current request.
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidclearCurrentFlashCookieData()Clears all "current" flash data.booleancontains(String key)Checks if the key exists in the "current" flash data.voiddiscard()Discards all "outgoing" flash data but retains all "current" flash data.voiddiscard(String key)Discards the key from the "outgoing" flash data but retains it in the "current" flash data.voiderror(String value)Same as callingflash.put("error", "your value");.Stringget(String key)Gets a value if its in either the "current" or "outgoing" flash data.Map<String,String>getCurrentFlashCookieData()Gets all "current" flash data.Map<String,String>getOutgoingFlashCookieData()Gets all "outgoing" flash data.voidinit(Context context)Intended for use by implementations only.voidkeep()Copies all "current" flash data into the "outgoing" flash data.voidkeep(String key)Will copy the "current" flash data specified by the key into the "outgoing" flash data.voidnow(String key, String value)Puts the key and value into only the "current" flash data.voidput(String key, Object value)Deprecated.Convert your value to a String in your application since this method implies Serialization could be used (which is not true).voidput(String key, String value)Puts the key and value into both "current" and "outgoing" flash data.booleanremove(String key)Removes a value completely from both "current" and "outgoing" flash data.voidsave(Context context)Intended for use by implementations only.voidsuccess(String value)Same as callingflash.put("success", "your value");.
 
- 
- 
- 
Method Detail- 
initvoid init(Context context) Intended for use by implementations only. Initializes the FlashScope from the context. Ninja will call this when a new request is being handled.- Parameters:
- context- The Ninja context
 
 - 
savevoid save(Context context) Intended for use by implementations only. Saves the FlashScope to the context. Will write/delete cookies, etc. Ninja will call this when a request will be completed.- Parameters:
- context- The Ninja context
 
 - 
getString get(String key) Gets a value if its in either the "current" or "outgoing" flash data.- Parameters:
- key- The flash key
- Returns:
- The flash value or null if none exists by that key
 
 - 
removeboolean remove(String key) Removes a value completely from both "current" and "outgoing" flash data.- Parameters:
- key- The flash key
- Returns:
- True if removed or false if it didn't exist
 
 - 
containsboolean contains(String key) Checks if the key exists in the "current" flash data.- Parameters:
- key- The flash key
- Returns:
- True if the key exists or false if it doesn't
 
 - 
nowvoid now(String key, String value) Puts the key and value into only the "current" flash data. Will NOT be written as a cookie and will only exist for the current request. Accessible via ${flash.key} in your html templating engine.- Parameters:
- key- The flash key
- value- The i18n key used to retrieve value of that message OR an already translated message (if your template engine supports it)
- See Also:
- If you need the value for both the current and next request
 
 - 
putvoid put(String key, String value) Puts the key and value into both "current" and "outgoing" flash data. Will be written as a cookie and available in the current and next request. If you only need the value in your current request its a good idea to use thenow()method instead so you can eliminate the possibility of showing unexpected flash messages on the next request :-).- Parameters:
- key- The flash key
- value- The i18n key used to retrieve value of that message OR an already translated message (if your template engine supports it)
- See Also:
- If you only need the value in your current request.
 
 - 
put@Deprecated void put(String key, Object value) Deprecated.Convert your value to a String in your application since this method implies Serialization could be used (which is not true).
 - 
discardvoid discard(String key) Discards the key from the "outgoing" flash data but retains it in the "current" flash data.- Parameters:
- key- The flash key
- See Also:
- To reverse this operation and keep the key as part of the "outgoing" flash data.
 
 - 
discardvoid discard() Discards all "outgoing" flash data but retains all "current" flash data.
 - 
keepvoid keep(String key) Will copy the "current" flash data specified by the key into the "outgoing" flash data.- Parameters:
- key- The flash key
 
 - 
keepvoid keep() Copies all "current" flash data into the "outgoing" flash data.
 - 
errorvoid error(String value) Same as callingflash.put("error", "your value");. The value will be added to both "current" and "outgoing" flash data.- Parameters:
- value- The i18n key used to retrieve value of that message OR an already translated message (if your template engine supports it)
 
 - 
successvoid success(String value) Same as callingflash.put("success", "your value");. The value will be added to both "current" and "outgoing" flash data.- Parameters:
- value- The i18n key used to retrieve value of that message OR an already translated message (if your template engine supports it)
 
 - 
clearCurrentFlashCookieDatavoid clearCurrentFlashCookieData() Clears all "current" flash data. If you need to ensure all "current" and "outgoing" flash data is deleted then call this as well as discard().
 - 
getCurrentFlashCookieDataMap<String,String> getCurrentFlashCookieData() Gets all "current" flash data.- Returns:
- All current flash data
 
 
- 
 
-