public class FlashScopeImpl extends Object implements FlashScope
Constructor and Description |
---|
FlashScopeImpl(NinjaProperties ninjaProperties) |
Modifier and Type | Method and Description |
---|---|
void |
clearCurrentFlashCookieData()
Clears all "current" flash data.
|
boolean |
contains(String key)
Checks if the key exists in the "current" flash data.
|
void |
discard()
Discards all "outgoing" flash data but retains all "current" flash data.
|
void |
discard(String key)
Discards the key from the "outgoing" flash data but retains it in the
"current" flash data.
|
void |
error(String value)
Same as calling
flash.put("error", "your value"); . |
String |
get(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.
|
void |
init(Context context)
Intended for use by implementations only.
|
void |
keep()
Copies all "current" flash data into the "outgoing" flash data.
|
void |
keep(String key)
Will copy the "current" flash data specified by the key into the "outgoing"
flash data.
|
void |
now(String key,
String value)
Puts the key and value into only the "current" flash data.
|
void |
put(String key,
Object value) |
void |
put(String key,
String value)
Puts the key and value into both "current" and "outgoing" flash data.
|
boolean |
remove(String key)
Removes a value completely from both "current" and "outgoing" flash data.
|
void |
save(Context context)
Intended for use by implementations only.
|
void |
success(String value)
Same as calling
flash.put("success", "your value"); . |
@Inject public FlashScopeImpl(NinjaProperties ninjaProperties)
public void init(Context context)
FlashScope
init
in interface FlashScope
context
- The Ninja contextpublic void save(Context context)
FlashScope
save
in interface FlashScope
context
- The Ninja contextpublic void now(String key, String value)
FlashScope
now
in interface FlashScope
key
- The flash keyvalue
- The i18n key used to retrieve value of that message
OR an already translated message (if your template engine supports it)If you need the value for
both the current and next request
public String get(String key)
FlashScope
get
in interface FlashScope
key
- The flash keypublic boolean remove(String key)
FlashScope
remove
in interface FlashScope
key
- The flash keypublic boolean contains(String key)
FlashScope
contains
in interface FlashScope
key
- The flash keypublic void put(String key, String value)
FlashScope
now()
method instead so you can eliminate the possibility
of showing unexpected flash messages on the next request :-).put
in interface FlashScope
key
- The flash keyvalue
- The i18n key used to retrieve value of that message
OR an already translated message (if your template engine supports it)If you only need the value
in your current request.
public void put(String key, Object value)
put
in interface FlashScope
public void error(String value)
FlashScope
flash.put("error", "your value");
. The value
will be added to both "current" and "outgoing" flash data.error
in interface FlashScope
value
- The i18n key used to retrieve value of that message
OR an already translated message (if your template engine supports it)public void success(String value)
FlashScope
flash.put("success", "your value");
. The value
will be added to both "current" and "outgoing" flash data.success
in interface FlashScope
value
- The i18n key used to retrieve value of that message
OR an already translated message (if your template engine supports it)public void discard(String key)
FlashScope
discard
in interface FlashScope
key
- The flash keyTo reverse this operation and keep the key
as part of the "outgoing" flash data.
public void discard()
FlashScope
discard
in interface FlashScope
To reverse this operation and keep all keys as part of the
"outgoing" flash data.
public void keep(String key)
FlashScope
keep
in interface FlashScope
key
- The flash keypublic void keep()
FlashScope
keep
in interface FlashScope
public void clearCurrentFlashCookieData()
FlashScope
clearCurrentFlashCookieData
in interface FlashScope
public Map<String,String> getCurrentFlashCookieData()
FlashScope
getCurrentFlashCookieData
in interface FlashScope
public Map<String,String> getOutgoingFlashCookieData()
FlashScope
getOutgoingFlashCookieData
in interface FlashScope
Copyright © 2019 ninjaframework. All rights reserved.