Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Code Block
titleStateful.java
interface Stateful {

public void saveState(Page page, Context context)
// public void saveState(Page page, Context context, Map options)??
  // By default save in session under its name+page path
 // This method can call getState to retrieve this components state
  // Optimization includes GZIP compressing the state


public void restoreState(Page page, Context context)
//public void restoreState(Page page, Context context, Map options)??
  // Grab state from session and invoke setState

public Object getState() {
  // Assemble state and return as object. This allows developers to save state in cookie instead.
// It also allows parent containers to assemble its children state recursively
// If this control is a container it should assemble all its child control state.
}

public void setState(Object state) {
    // Cast object back to its type and set state to this control and its children
}

Some useful utilities include:

Code Block
titleClickUtils.java
public static Stringvoid getStateFormatted(saveState(Stateful stateful, Context context) {
// public static void saveState(Stateful stateful, Context context, Map options)??
  // Return a user friendly presentation of the stateBy default save state in session in a map that is stored against the request page path
 // This method can call stateful.getState to retrieve this components state
  // Optimization includes GZIP compressing the state


public static void restoreState(Stateful stateful, Context context) {
  //public static void restoreState(Context context, Map options)??
  // Grab state from session and invoke stateful.setState
}

Each control will be responsible for storing it's own state as well as it's children. It's up to the control or container how to best store thee the state, but shouldange should keep the following in mind:

...