KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > form > MockForm


1 // Copyright 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.form;
16
17 import java.util.ArrayList JavaDoc;
18 import java.util.Collection JavaDoc;
19 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import org.apache.hivemind.Location;
24 import org.apache.hivemind.Messages;
25 import org.apache.tapestry.IAsset;
26 import org.apache.tapestry.IBeanProvider;
27 import org.apache.tapestry.IBinding;
28 import org.apache.tapestry.IComponent;
29 import org.apache.tapestry.IForm;
30 import org.apache.tapestry.IMarkupWriter;
31 import org.apache.tapestry.INamespace;
32 import org.apache.tapestry.IPage;
33 import org.apache.tapestry.IRender;
34 import org.apache.tapestry.IRequestCycle;
35 import org.apache.tapestry.engine.IPageLoader;
36 import org.apache.tapestry.listener.ListenerMap;
37 import org.apache.tapestry.spec.IComponentSpecification;
38 import org.apache.tapestry.valid.IValidationDelegate;
39
40 /**
41  * Mock object used by the {@link org.apache.tapestry.form.TestFormSupport}.
42  *
43  * @author Howard M. Lewis Ship
44  * @since 4.0
45  */

46 public class MockForm implements IForm
47 {
48     private Location _location;
49
50     private IRender _body;
51
52     private List JavaDoc _deferredRunnable = new ArrayList JavaDoc();
53
54     private IValidationDelegate _delegate;
55
56     public MockForm()
57     {
58         this(null, null);
59     }
60
61     public MockForm(Location location)
62     {
63         this(null, location);
64     }
65
66     public MockForm(IValidationDelegate delegate)
67     {
68         this(delegate, null);
69     }
70
71     public MockForm(IValidationDelegate delegate, Location location)
72     {
73         _delegate = delegate;
74         _location = location;
75     }
76
77     public void rewind(IMarkupWriter writer, IRequestCycle cycle)
78     {
79     }
80
81     public void addEventHandler(FormEventType type, String JavaDoc functionName)
82     {
83     }
84
85     public String JavaDoc getElementId(IFormComponent component)
86     {
87         return null;
88     }
89
90     public String JavaDoc getElementId(IFormComponent component, String JavaDoc baseId)
91     {
92         return null;
93     }
94
95     public String JavaDoc getName()
96     {
97         return "myform";
98     }
99
100     public boolean isRewinding()
101     {
102         return false;
103     }
104
105     public IValidationDelegate getDelegate()
106     {
107         return _delegate;
108     }
109
110     public void setEncodingType(String JavaDoc encodingType)
111     {
112     }
113
114     public void addHiddenValue(String JavaDoc name, String JavaDoc value)
115     {
116     }
117
118     public void addHiddenValue(String JavaDoc name, String JavaDoc id, String JavaDoc value)
119     {
120     }
121
122     public boolean getRequiresSession()
123     {
124         return false;
125     }
126
127     public void addAsset(String JavaDoc name, IAsset asset)
128     {
129     }
130
131     public void addComponent(IComponent component)
132     {
133     }
134
135     public void addBody(IRender element)
136     {
137     }
138
139     public Map JavaDoc getAssets()
140     {
141         return null;
142     }
143
144     public IAsset getAsset(String JavaDoc name)
145     {
146         return null;
147     }
148
149     public IBinding getBinding(String JavaDoc name)
150     {
151         return null;
152     }
153
154     public Collection JavaDoc getBindingNames()
155     {
156         return null;
157     }
158
159     public Map JavaDoc getBindings()
160     {
161         return null;
162     }
163
164     public IComponent getComponent(String JavaDoc id)
165     {
166         return null;
167     }
168
169     public IComponent getContainer()
170     {
171         return null;
172     }
173
174     public void setContainer(IComponent value)
175     {
176     }
177
178     public String JavaDoc getExtendedId()
179     {
180         return "SomePage/myform";
181     }
182
183     public String JavaDoc getId()
184     {
185         return null;
186     }
187
188     public void setId(String JavaDoc value)
189     {
190     }
191
192     public String JavaDoc getIdPath()
193     {
194         return null;
195     }
196
197     public IPage getPage()
198     {
199         return null;
200     }
201
202     public void setPage(IPage value)
203     {
204     }
205
206     public IComponentSpecification getSpecification()
207     {
208         return null;
209     }
210
211     public void renderBody(IMarkupWriter writer, IRequestCycle cycle)
212     {
213         if (_body != null)
214             _body.render(writer, cycle);
215     }
216
217     public void setBinding(String JavaDoc name, IBinding binding)
218     {
219     }
220
221     public Map JavaDoc getComponents()
222     {
223         return null;
224     }
225
226     public void finishLoad(IRequestCycle cycle, IPageLoader loader,
227             IComponentSpecification specification)
228     {
229     }
230
231     public Messages getMessages()
232     {
233         return null;
234     }
235
236     public INamespace getNamespace()
237     {
238         return null;
239     }
240
241     public void setNamespace(INamespace namespace)
242     {
243     }
244
245     public void setProperty(String JavaDoc propertyName, Object JavaDoc value)
246     {
247     }
248
249     public Object JavaDoc getProperty(String JavaDoc propertyName)
250     {
251         return null;
252     }
253
254     public boolean isRendering()
255     {
256         return false;
257     }
258
259     public void enterActiveState()
260     {
261     }
262
263     public IBeanProvider getBeans()
264     {
265         return null;
266     }
267
268     public ListenerMap getListeners()
269     {
270         return null;
271     }
272
273     public void render(IMarkupWriter writer, IRequestCycle cycle)
274     {
275     }
276
277     public void setLocation(Location arg0)
278     {
279     }
280
281     public Location getLocation()
282     {
283         return _location;
284     }
285
286     public void setBody(IRender body)
287     {
288         _body = body;
289     }
290
291     public void prerenderField(IMarkupWriter writer, IComponent field, Location location)
292     {
293     }
294
295     public boolean wasPrerendered(IMarkupWriter writer, IComponent field)
296     {
297         return false;
298     }
299
300     public void addDeferredRunnable(Runnable JavaDoc runnable)
301     {
302         _deferredRunnable.add(runnable);
303     }
304
305     void runDeferred()
306     {
307         Iterator JavaDoc i = _deferredRunnable.iterator();
308         while (i.hasNext())
309         {
310             Runnable JavaDoc r = (Runnable JavaDoc) i.next();
311
312             r.run();
313         }
314     }
315
316     public boolean isClientValidationEnabled()
317     {
318         return false;
319     }
320
321     public String JavaDoc getMessage(String JavaDoc key)
322     {
323         return null;
324     }
325 }
Popular Tags