|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.shale.dialog.base.AbstractDialogContextListener org.apache.shale.dialog.base.StateSavingListener
public class StateSavingListener
Convenience DialogContextListener
implementation that supports
saving and restoring pre-request state information that is accessed via
a configurable set of value binding expressions. Whenever the associated
DialogContext
is passivated (such as at the end of a request), the
getValue()
method will be called on each value binding, to
save away the retrieved information internally to this instance. Later,
when a POST causes our DialogContext
instance to be activated again,
setValue()
will be called on each value binding, to restore the
saved data to its original location.
The most common use case for this class will be as the base class for
a class that is registered as the data
class for a particular
dialog. When used in this manner:
DialogContext
instance is created, a new instance
of the registered class will also be instantiated, and assigned to the
data
property of the DialogContext
instance.DialogContextListener
, it will
automatically be registered as a listener on the DialogContext
instance, causing our onActivate()
and onPassivate
methods to be called at the appropriate times.expressions
property, as described above.So, if you wish to use this mechanism to save and restore the
foo
and bar
request scoped variables, create a
subclass like this:
public class MyStateSavingListener extends StateSavingListener { public MyStateSavingListener() { setExpressions(new String[] { "#{foo}", "#{bar}" }); } }
Next, cause this class to be registered as the standard data
class in the configuraiton for this dialog. The details will vary depending
on which dialog implementation you are using. Now, the specified state
information will be saved and restored for you.
IMPLEMENTATION NOTE - Because this instance will be stored in session scope, all of the data saved via the configured value binding expressions is expected to be serializable.
Constructor Summary | |
---|---|
StateSavingListener()
|
Method Summary | |
---|---|
String[] |
getExpressions()
Return an array of value binding expressions that identify state information to be saved and restored. |
void |
onActivate()
Restore the values specified by our configured expressions. |
void |
onPassivate()
Save the values specified by our configured expressions. |
void |
setExpressions(String[] expressions)
Set the array of value binding expressions that identify state information to be saved and restored. |
Methods inherited from class org.apache.shale.dialog.base.AbstractDialogContextListener |
---|
getDialogContext, onEntry, onException, onExit, onStart, onStop, onTransition, setDialogContext |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StateSavingListener()
Method Detail |
---|
public String[] getExpressions()
Return an array of value binding expressions that identify state information to be saved and restored.
public void setExpressions(String[] expressions)
Set the array of value binding expressions that identify state information to be saved and restored.
expressions
- The new expressionspublic void onActivate()
Restore the values specified by our configured expressions.
onActivate
in interface DialogContextListener
onActivate
in class AbstractDialogContextListener
DialogContextListener.onActivate()
public void onPassivate()
Save the values specified by our configured expressions.
onPassivate
in interface DialogContextListener
onPassivate
in class AbstractDialogContextListener
DialogContextListener.onPassivate()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |