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 return _submitted;
50 }
51
52 public void setSubmitted(boolean submitted)
53 {
54 _submitted = submitted;
55 }
56
57 public void processDecodes(javax.faces.context.FacesContext context)
58 {
59 if (context == null)
60 {
61 throw new NullPointerException("context");
62 }
63 try
64 {
65 setCachedFacesContext(context);
66 decode(context);
67 if (!isSubmitted()) return;
68 for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
69 {
70 UIComponent childOrFacet = (UIComponent)it.next();
71 childOrFacet.processDecodes(context);
72 }
73 }
74 finally
75 {
76 setCachedFacesContext(null);
77 }
78 }
79
80 public void processValidators(javax.faces.context.FacesContext context)
81 {
82 if (context == null)
83 {
84 throw new NullPointerException("context");
85 }
86 try
87 {
88 setCachedFacesContext(context);
89
90
91
92 if (!isSubmitted()) {
93 decode(context);
94 }
95 if (!isSubmitted()) return;
96 for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
97 {
98 UIComponent childOrFacet = (UIComponent)it.next();
99 childOrFacet.processValidators(context);
100 }
101 }
102 finally
103 {
104 setCachedFacesContext(null);
105 }
106 }
107
108 public void processUpdates(javax.faces.context.FacesContext context)
109 {
110 if (context == null)
111 {
112 throw new NullPointerException("context");
113 }
114 try
115 {
116 setCachedFacesContext(context);
117
118
119
120 if (!isSubmitted()) {
121 decode(context);
122 }
123 if (!isSubmitted()) return;
124 for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
125 {
126 UIComponent childOrFacet = (UIComponent)it.next();
127 childOrFacet.processUpdates(context);
128 }
129 }
130 finally
131 {
132 setCachedFacesContext(null);
133 }
134 }
135
136 public Object saveState(javax.faces.context.FacesContext context)
137 {
138 Object[] state = new Object[2];
139 state[0] = super.saveState(context);
140 state[1] = _prependId;
141 return state;
142 }
143
144 @Override
145 public void restoreState(FacesContext context, Object state)
146 {
147 Object[] values = (Object[]) state;
148 super.restoreState(context, values[0]);
149 _prependId = (Boolean) values[1];
150 }
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 {
161 setRendererType(DEFAULT_RENDERER_TYPE);
162 }
163
164 public String getFamily()
165 {
166 return COMPONENT_FAMILY;
167 }
168
169
170
171
172 public String getContainerClientId(FacesContext ctx)
173 {
174 if (isPrependId())
175 {
176 return super.getContainerClientId(ctx);
177 }
178 UIComponent parentNamingContainer = _ComponentUtils.findParentNamingContainer(this, false);
179 if (parentNamingContainer != null)
180 {
181 return parentNamingContainer.getContainerClientId(ctx);
182 }
183 return null;
184 }
185
186 @JSFProperty(defaultValue = "true")
187 public boolean isPrependId()
188 {
189 return getExpressionValue("prependId", _prependId, true);
190 }
191
192 public void setPrependId(boolean prependId)
193 {
194 _prependId = prependId;
195 }
196
197 }