|
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 |
6
| FormComponentContributorContextImpl(IFormComponent field)
|
|
51 |
| { |
|
52 |
6
| super(field, Locale.ENGLISH);
|
|
53 |
| |
|
54 |
6
| _field = field;
|
|
55 |
6
| _resolver = null;
|
|
56 |
6
| _formId = null;
|
|
57 |
6
| _pageRenderSupport = null;
|
|
58 |
6
| _form = null;
|
|
59 |
| } |
|
60 |
| |
|
61 |
15
| public FormComponentContributorContextImpl(Locale locale, IRequestCycle cycle,
|
|
62 |
| IFormComponent field) |
|
63 |
| { |
|
64 |
15
| super(field, locale);
|
|
65 |
| |
|
66 |
15
| _field = field;
|
|
67 |
15
| _form = field.getForm();
|
|
68 |
15
| _formId = _form.getName();
|
|
69 |
| |
|
70 |
15
| _resolver = cycle.getInfrastructure().getClassResolver();
|
|
71 |
| |
|
72 |
15
| _pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, field);
|
|
73 |
| } |
|
74 |
| |
|
75 |
3
| public void includeClasspathScript(String path)
|
|
76 |
| { |
|
77 |
3
| Resource resource = new ClasspathResource(_resolver, path);
|
|
78 |
| |
|
79 |
3
| _pageRenderSupport.addExternalScript(resource);
|
|
80 |
| } |
|
81 |
| |
|
82 |
3
| public void addSubmitHandler(String submitListener)
|
|
83 |
| { |
|
84 |
3
| _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 |
| } |