|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AbstractFormComponentContributor.java | 100% | 50% | 50% | 57.1% |
|
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 org.apache.hivemind.util.PropertyUtils; | |
18 | import org.apache.tapestry.IMarkupWriter; | |
19 | import org.apache.tapestry.IRequestCycle; | |
20 | ||
21 | /** | |
22 | * Abstract {@link FormComponentContributor} implementation that adds an optional static javscript | |
23 | * method reference to the page. | |
24 | * | |
25 | * @author Paul Ferraro | |
26 | * @since 4.0 | |
27 | */ | |
28 | public abstract class AbstractFormComponentContributor implements FormComponentContributor | |
29 | { | |
30 | private String _script = defaultScript(); | |
31 | ||
32 | 70 | public AbstractFormComponentContributor() |
33 | { | |
34 | } | |
35 | ||
36 | // Needed until HIVEMIND-134 fix is available | |
37 | 0 | public AbstractFormComponentContributor(String initializer) |
38 | { | |
39 | 0 | PropertyUtils.configureProperties(this, initializer); |
40 | } | |
41 | ||
42 | /** | |
43 | * Defines the default JavaScript file used by this contributor. Overriden by most subclasses | |
44 | * that use JavaScript. | |
45 | */ | |
46 | 42 | protected String defaultScript() |
47 | { | |
48 | 42 | return null; |
49 | } | |
50 | ||
51 | 0 | public String getScript() |
52 | { | |
53 | 0 | return _script; |
54 | } | |
55 | ||
56 | 0 | public void setScript(String script) |
57 | { | |
58 | 0 | _script = script; |
59 | } | |
60 | ||
61 | /** | |
62 | * @see org.apache.tapestry.form.FormComponentContributor#renderContribution(org.apache.tapestry.IMarkupWriter, | |
63 | * org.apache.tapestry.IRequestCycle, FormComponentContributorContext, | |
64 | * org.apache.tapestry.form.IFormComponent) | |
65 | */ | |
66 | 14 | public void renderContribution(IMarkupWriter writer, IRequestCycle cycle, |
67 | FormComponentContributorContext context, IFormComponent field) | |
68 | { | |
69 | 14 | if (_script != null) |
70 | 6 | context.includeClasspathScript(_script); |
71 | } | |
72 | } |
|