1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package javax.faces.render;
20
21 import javax.faces.application.StateManager;
22 import javax.faces.application.StateManager.SerializedView;
23 import javax.faces.context.FacesContext;
24 import java.io.IOException;
25
26
27
28
29 public abstract class ResponseStateManager
30 {
31 public static final String RENDER_KIT_ID_PARAM = "javax.faces.RenderKitId";
32 public static final String VIEW_STATE_PARAM = "javax.faces.ViewState";
33
34 public static final String CLIENT_WINDOW_PARAM = "javax.faces.ClientWindow";
35 public static final String CLIENT_WINDOW_URL_PARAM = "jfwid";
36
37 public static final String NON_POSTBACK_VIEW_TOKEN_PARAM = "javax.faces.Token";
38
39 public void writeState(FacesContext context, Object state) throws IOException
40 {
41 SerializedView view;
42 if (state instanceof SerializedView)
43 {
44 view = (SerializedView)state;
45 }
46 else if (state instanceof Object[])
47 {
48 Object[] structureAndState = (Object[])state;
49
50 if (structureAndState.length == 2)
51 {
52 Object structureObj = structureAndState[0];
53 Object stateObj = structureAndState[1];
54
55 StateManager stateManager = context.getApplication().getStateManager();
56 view = stateManager.new SerializedView(structureObj, stateObj);
57 }
58 else
59 {
60 throw new IOException("The state should be an array of Object[] of lenght 2");
61 }
62 }
63 else
64 {
65 throw new IOException("The state should be an array of Object[] of lenght 2, or a SerializedView instance");
66 }
67
68 writeState(context, view);
69 }
70
71
72
73
74
75 public void writeState(FacesContext context, StateManager.SerializedView state) throws IOException
76 {
77
78 }
79
80
81
82
83
84
85
86
87 public String getViewState(FacesContext context, Object state)
88 {
89
90
91 return null;
92 }
93
94
95
96
97 public Object getState(FacesContext context, String viewId)
98 {
99 Object[] structureAndState = new Object[2];
100 structureAndState[0] = getTreeStructureToRestore(context, viewId);
101 structureAndState[1] = getComponentStateToRestore(context);
102 return structureAndState;
103 }
104
105
106
107
108 public Object getTreeStructureToRestore(FacesContext context, String viewId)
109 {
110 return null;
111 }
112
113
114
115
116 public Object getComponentStateToRestore(FacesContext context)
117 {
118 return null;
119 }
120
121
122
123
124
125
126 public boolean isPostback(FacesContext context)
127 {
128 return context.getExternalContext().getRequestParameterMap().containsKey(ResponseStateManager.VIEW_STATE_PARAM);
129 }
130
131
132
133
134
135
136 public String getCryptographicallyStrongTokenFromSession(FacesContext context)
137 {
138 return null;
139 }
140
141
142
143
144
145
146
147 public boolean isStateless(FacesContext context, String viewId)
148 {
149 return false;
150 }
151 }