|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.click.util.FlashAttribute
public class FlashAttribute
Provides a flash session attribute. The flash attribute simply wraps an existing session attribute providing a marker to the Context and SessionMap classes that the session attribute should be removed once it has been accessed.
Flash session attributes appear only once in a session, after they have been accessed they are removed from the session. Flash attributes are typically used for display information messages to a user, and can be used with page redirects. Note you generally do not use FlashAttribute directly, but indirectly via the Context setFlashAttribute() method. For example:public boolean onOkClick() { // Perform logic .. String message = "Operation successfully completed"; getContext().setFlashAttribute("message", message); setRedirect(HomePage.class); return false; }To test for the existence of a flash attribute and then render it, you should set it as a variable in your template, because once it has been accessed from the session it is removed. Using Velocity as an example:
#set ($message = $session.message) #if ($message) <p>$message</p> #end
Context,
SessionMap,
Serialized Form| Field Summary | |
|---|---|
protected Object |
value
The session attribute value. |
| Constructor Summary | |
|---|---|
FlashAttribute(Object value)
Create a session flash attribute with the given value. |
|
| Method Summary | |
|---|---|
Object |
getValue()
Return the flash session attribute value. |
String |
toString()
Return the string representation of the flash attribute. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Object value
| Constructor Detail |
|---|
public FlashAttribute(Object value)
value - the flash session attribute value| Method Detail |
|---|
public Object getValue()
public String toString()
toString in class ObjectObject.toString()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||