1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package javax.faces.component; |
20 | |
|
21 | |
import java.util.Iterator; |
22 | |
|
23 | |
import javax.faces.context.FacesContext; |
24 | |
|
25 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent; |
26 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
@JSFComponent(type = "javax.faces.Form", |
36 | |
family = "javax.faces.Form") |
37 | |
public class UIForm |
38 | |
extends UIComponentBase |
39 | |
implements NamingContainer |
40 | |
{ |
41 | |
|
42 | |
|
43 | |
private boolean _submitted; |
44 | |
|
45 | |
private Boolean _prependId; |
46 | |
|
47 | |
public boolean isSubmitted() |
48 | |
{ |
49 | 0 | return _submitted; |
50 | |
} |
51 | |
|
52 | |
public void setSubmitted(boolean submitted) |
53 | |
{ |
54 | 0 | _submitted = submitted; |
55 | 0 | } |
56 | |
|
57 | |
public void processDecodes(javax.faces.context.FacesContext context) |
58 | |
{ |
59 | 0 | if (context == null) |
60 | |
{ |
61 | 0 | throw new NullPointerException("context"); |
62 | |
} |
63 | |
try |
64 | |
{ |
65 | 0 | setCachedFacesContext(context); |
66 | 0 | decode(context); |
67 | 0 | if (!isSubmitted()) return; |
68 | 0 | for (Iterator it = getFacetsAndChildren(); it.hasNext(); ) |
69 | |
{ |
70 | 0 | UIComponent childOrFacet = (UIComponent)it.next(); |
71 | 0 | childOrFacet.processDecodes(context); |
72 | 0 | } |
73 | |
} |
74 | |
finally |
75 | |
{ |
76 | 0 | setCachedFacesContext(null); |
77 | 0 | } |
78 | 0 | } |
79 | |
|
80 | |
public void processValidators(javax.faces.context.FacesContext context) |
81 | |
{ |
82 | 0 | if (context == null) |
83 | |
{ |
84 | 0 | throw new NullPointerException("context"); |
85 | |
} |
86 | |
try |
87 | |
{ |
88 | 0 | setCachedFacesContext(context); |
89 | |
|
90 | |
|
91 | |
|
92 | 0 | if (!isSubmitted()) { |
93 | 0 | decode(context); |
94 | |
} |
95 | 0 | if (!isSubmitted()) return; |
96 | 0 | for (Iterator it = getFacetsAndChildren(); it.hasNext(); ) |
97 | |
{ |
98 | 0 | UIComponent childOrFacet = (UIComponent)it.next(); |
99 | 0 | childOrFacet.processValidators(context); |
100 | 0 | } |
101 | |
} |
102 | |
finally |
103 | |
{ |
104 | 0 | setCachedFacesContext(null); |
105 | 0 | } |
106 | 0 | } |
107 | |
|
108 | |
public void processUpdates(javax.faces.context.FacesContext context) |
109 | |
{ |
110 | 0 | if (context == null) |
111 | |
{ |
112 | 0 | throw new NullPointerException("context"); |
113 | |
} |
114 | |
try |
115 | |
{ |
116 | 0 | setCachedFacesContext(context); |
117 | |
|
118 | |
|
119 | |
|
120 | 0 | if (!isSubmitted()) { |
121 | 0 | decode(context); |
122 | |
} |
123 | 0 | if (!isSubmitted()) return; |
124 | 0 | for (Iterator it = getFacetsAndChildren(); it.hasNext(); ) |
125 | |
{ |
126 | 0 | UIComponent childOrFacet = (UIComponent)it.next(); |
127 | 0 | childOrFacet.processUpdates(context); |
128 | 0 | } |
129 | |
} |
130 | |
finally |
131 | |
{ |
132 | 0 | setCachedFacesContext(null); |
133 | 0 | } |
134 | 0 | } |
135 | |
|
136 | |
public Object saveState(javax.faces.context.FacesContext context) |
137 | |
{ |
138 | 0 | Object[] state = new Object[2]; |
139 | 0 | state[0] = super.saveState(context); |
140 | 0 | state[1] = _prependId; |
141 | 0 | return state; |
142 | |
} |
143 | |
|
144 | |
@Override |
145 | |
public void restoreState(FacesContext context, Object state) |
146 | |
{ |
147 | 0 | Object[] values = (Object[]) state; |
148 | 0 | super.restoreState(context, values[0]); |
149 | 0 | _prependId = (Boolean) values[1]; |
150 | 0 | } |
151 | |
|
152 | |
|
153 | |
|
154 | |
public static final String COMPONENT_TYPE = "javax.faces.Form"; |
155 | |
public static final String COMPONENT_FAMILY = "javax.faces.Form"; |
156 | |
private static final String DEFAULT_RENDERER_TYPE = "javax.faces.Form"; |
157 | |
|
158 | |
|
159 | |
public UIForm() |
160 | 0 | { |
161 | 0 | setRendererType(DEFAULT_RENDERER_TYPE); |
162 | 0 | } |
163 | |
|
164 | |
public String getFamily() |
165 | |
{ |
166 | 0 | return COMPONENT_FAMILY; |
167 | |
} |
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
public String getContainerClientId(FacesContext ctx) |
173 | |
{ |
174 | 0 | if (isPrependId()) |
175 | |
{ |
176 | 0 | return super.getContainerClientId(ctx); |
177 | |
} |
178 | 0 | UIComponent parentNamingContainer = _ComponentUtils.findParentNamingContainer(this, false); |
179 | 0 | if (parentNamingContainer != null) |
180 | |
{ |
181 | 0 | return parentNamingContainer.getContainerClientId(ctx); |
182 | |
} |
183 | 0 | return null; |
184 | |
} |
185 | |
|
186 | |
@JSFProperty(defaultValue = "true") |
187 | |
public boolean isPrependId() |
188 | |
{ |
189 | 0 | return getExpressionValue("prependId", _prependId, true); |
190 | |
} |
191 | |
|
192 | |
public void setPrependId(boolean prependId) |
193 | |
{ |
194 | 0 | _prependId = prependId; |
195 | 0 | } |
196 | |
|
197 | |
} |