| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package javax.faces.application; |
| 17 | |
|
| 18 | |
import java.io.IOException; |
| 19 | |
import java.io.Serializable; |
| 20 | |
|
| 21 | |
import javax.faces.component.UIViewRoot; |
| 22 | |
import javax.faces.context.FacesContext; |
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | 1365 | public abstract class StateManager implements Serializable { |
| 28 | |
|
| 29 | |
public static final String STATE_SAVING_METHOD_CLIENT = "client"; |
| 30 | |
|
| 31 | |
public static final String STATE_SAVING_METHOD_SERVER = "server"; |
| 32 | |
|
| 33 | |
public static final String STATE_SAVING_METHOD_PARAM_NAME = "javax.faces.STATE_SAVING_METHOD"; |
| 34 | |
|
| 35 | |
public abstract SerializedView saveSerializedView(FacesContext context); |
| 36 | |
|
| 37 | |
public abstract void writeState(FacesContext context, SerializedView state) |
| 38 | |
throws IOException; |
| 39 | |
|
| 40 | |
protected abstract Object getTreeStructureToSave(FacesContext context); |
| 41 | |
|
| 42 | |
protected abstract Object getComponentStateToSave(FacesContext context); |
| 43 | |
|
| 44 | |
public abstract UIViewRoot restoreView(FacesContext context, String viewId, |
| 45 | |
String renderKitId); |
| 46 | |
|
| 47 | |
protected abstract UIViewRoot restoreTreeStructure(FacesContext context, |
| 48 | |
String viewId, String renderKitId); |
| 49 | |
|
| 50 | |
protected abstract void restoreComponentState(FacesContext context, |
| 51 | |
UIViewRoot viewRoot, String renderKitId); |
| 52 | |
|
| 53 | |
public boolean isSavingStateInClient(FacesContext context) { |
| 54 | 19 | String state = getSavingState(context); |
| 55 | 18 | if (STATE_SAVING_METHOD_CLIENT.equalsIgnoreCase(state)) { |
| 56 | 6 | return true; |
| 57 | |
} |
| 58 | 12 | return false; |
| 59 | |
} |
| 60 | |
|
| 61 | |
private static String getSavingState(FacesContext context) { |
| 62 | 19 | return context.getExternalContext().getInitParameter( |
| 63 | |
STATE_SAVING_METHOD_PARAM_NAME); |
| 64 | |
} |
| 65 | |
|
| 66 | 1365 | public class SerializedView implements Serializable { |
| 67 | |
|
| 68 | |
private static final long serialVersionUID = 1L; |
| 69 | |
|
| 70 | 11 | private Object structure = null; |
| 71 | |
|
| 72 | 11 | private Object state = null; |
| 73 | |
|
| 74 | 11 | public SerializedView(Object structure, Object state) { |
| 75 | 11 | this.structure = structure; |
| 76 | 11 | this.state = state; |
| 77 | 11 | } |
| 78 | |
|
| 79 | |
public Object getState() { |
| 80 | 8 | return state; |
| 81 | |
} |
| 82 | |
|
| 83 | |
public Object getStructure() { |
| 84 | 9 | return structure; |
| 85 | |
} |
| 86 | |
} |
| 87 | |
|
| 88 | |
} |