1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.form; |
16 |
| |
17 |
| import java.util.Locale; |
18 |
| |
19 |
| import org.apache.hivemind.ClassResolver; |
20 |
| import org.apache.hivemind.Resource; |
21 |
| import org.apache.hivemind.util.ClasspathResource; |
22 |
| import org.apache.tapestry.IForm; |
23 |
| import org.apache.tapestry.IRequestCycle; |
24 |
| import org.apache.tapestry.PageRenderSupport; |
25 |
| import org.apache.tapestry.TapestryUtils; |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| public class FormComponentContributorContextImpl extends ValidationMessagesImpl implements |
34 |
| FormComponentContributorContext |
35 |
| { |
36 |
| private final ClassResolver _resolver; |
37 |
| |
38 |
| private final PageRenderSupport _pageRenderSupport; |
39 |
| |
40 |
| private final IFormComponent _field; |
41 |
| |
42 |
| private final IForm _form; |
43 |
| |
44 |
| private final String _formId; |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
2
| FormComponentContributorContextImpl(IFormComponent field)
|
51 |
| { |
52 |
2
| super(field, Locale.ENGLISH);
|
53 |
| |
54 |
2
| _field = field;
|
55 |
2
| _resolver = null;
|
56 |
2
| _formId = null;
|
57 |
2
| _pageRenderSupport = null;
|
58 |
2
| _form = null;
|
59 |
| } |
60 |
| |
61 |
5
| public FormComponentContributorContextImpl(Locale locale, IRequestCycle cycle,
|
62 |
| IFormComponent field) |
63 |
| { |
64 |
5
| super(field, locale);
|
65 |
| |
66 |
5
| _field = field;
|
67 |
5
| _form = field.getForm();
|
68 |
5
| _formId = _form.getName();
|
69 |
| |
70 |
5
| _resolver = cycle.getInfrastructure().getClassResolver();
|
71 |
| |
72 |
5
| _pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, field);
|
73 |
| } |
74 |
| |
75 |
1
| public void includeClasspathScript(String path)
|
76 |
| { |
77 |
1
| Resource resource = new ClasspathResource(_resolver, path);
|
78 |
| |
79 |
1
| _pageRenderSupport.addExternalScript(resource);
|
80 |
| } |
81 |
| |
82 |
1
| public void addSubmitHandler(String submitListener)
|
83 |
| { |
84 |
1
| _pageRenderSupport.addInitializationScript("Tapestry.onsubmit('" + _formId + "', "
|
85 |
| + submitListener + ");"); |
86 |
| } |
87 |
| |
88 |
0
| public void registerForFocus(int priority)
|
89 |
| { |
90 |
0
| _form.registerForFocus(_field, priority);
|
91 |
| } |
92 |
| |
93 |
| } |