You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Table of content

Background

With the deprecation of stateful pages we need a way to preserve control state across requests.

Proposal

Add a new interface that stateful controls can implement:

Stateful.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.
// 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
}

public String getStateAsString() {
  // Return a user friendly presentation of the state
}
  • No labels