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 | 520 | 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 | 0 | if (state instanceof SerializedView) |
43 | |
{ |
44 | 0 | view = (SerializedView)state; |
45 | |
} |
46 | 0 | else if (state instanceof Object[]) |
47 | |
{ |
48 | 0 | Object[] structureAndState = (Object[])state; |
49 | |
|
50 | 0 | if (structureAndState.length == 2) |
51 | |
{ |
52 | 0 | Object structureObj = structureAndState[0]; |
53 | 0 | Object stateObj = structureAndState[1]; |
54 | |
|
55 | 0 | StateManager stateManager = context.getApplication().getStateManager(); |
56 | 0 | view = stateManager.new SerializedView(structureObj, stateObj); |
57 | 0 | } |
58 | |
else |
59 | |
{ |
60 | 0 | throw new IOException("The state should be an array of Object[] of lenght 2"); |
61 | |
} |
62 | 0 | } |
63 | |
else |
64 | |
{ |
65 | 0 | throw new IOException("The state should be an array of Object[] of lenght 2, or a SerializedView instance"); |
66 | |
} |
67 | |
|
68 | 0 | writeState(context, view); |
69 | 0 | } |
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
public void writeState(FacesContext context, StateManager.SerializedView state) throws IOException |
76 | |
{ |
77 | |
|
78 | 0 | } |
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
public String getViewState(FacesContext context, Object state) |
88 | |
{ |
89 | |
|
90 | |
|
91 | 0 | return null; |
92 | |
} |
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
public Object getState(FacesContext context, String viewId) |
98 | |
{ |
99 | 0 | Object[] structureAndState = new Object[2]; |
100 | 0 | structureAndState[0] = getTreeStructureToRestore(context, viewId); |
101 | 0 | structureAndState[1] = getComponentStateToRestore(context); |
102 | 0 | return structureAndState; |
103 | |
} |
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
public Object getTreeStructureToRestore(FacesContext context, String viewId) |
109 | |
{ |
110 | 0 | return null; |
111 | |
} |
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
public Object getComponentStateToRestore(FacesContext context) |
117 | |
{ |
118 | 0 | return null; |
119 | |
} |
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
public boolean isPostback(FacesContext context) |
127 | |
{ |
128 | 0 | return context.getExternalContext().getRequestParameterMap().containsKey(ResponseStateManager.VIEW_STATE_PARAM); |
129 | |
} |
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
public String getCryptographicallyStrongTokenFromSession(FacesContext context) |
137 | |
{ |
138 | 0 | return null; |
139 | |
} |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
public boolean isStateless(FacesContext context, String viewId) |
148 | |
{ |
149 | 0 | return false; |
150 | |
} |
151 | |
} |