Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Submit |
|
| 1.6666666666666667;1.667 |
1 | // Copyright 2004, 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.tapestry.IMarkupWriter; | |
18 | import org.apache.tapestry.IRequestCycle; | |
19 | ||
20 | /** | |
21 | * Implements a component that manages an HTML <input type=submit> form element. [ <a | |
22 | * href="../../../../../components/form/submit.html">Component Reference </a>] | |
23 | * <p> | |
24 | * This component is generally only used when the form has multiple submit buttons, and it is | |
25 | * important for the application to know which one was pressed. You may also want to use | |
26 | * {@link ImageSubmit}which accomplishes much the same thing, but uses a graphic image instead. | |
27 | * | |
28 | * @author Howard Lewis Ship | |
29 | */ | |
30 | ||
31 | 0 | public abstract class Submit extends AbstractSubmit |
32 | { | |
33 | protected boolean isClicked(IRequestCycle cycle, String name) | |
34 | { | |
35 | // How to know which Submit button was actually | |
36 | // clicked? When submitted, it produces a request parameter | |
37 | // with its name and value (the value serves double duty as both | |
38 | // the label on the button, and the parameter value). | |
39 | ||
40 | // If the value isn't there, then this button wasn't | |
41 | // selected. | |
42 | ||
43 | 0 | return cycle.getParameter(name) != null; |
44 | } | |
45 | ||
46 | /** | |
47 | * @see org.apache.tapestry.form.AbstractFormComponent#renderFormComponent(org.apache.tapestry.IMarkupWriter, | |
48 | * org.apache.tapestry.IRequestCycle) | |
49 | */ | |
50 | protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle) | |
51 | { | |
52 | 0 | writer.beginEmpty("input"); |
53 | 0 | writer.attribute("type", "submit"); |
54 | 0 | writer.attribute("name", getName()); |
55 | ||
56 | 0 | if (isDisabled()) |
57 | 0 | writer.attribute("disabled", "disabled"); |
58 | ||
59 | 0 | String label = getLabel(); |
60 | ||
61 | 0 | if (label != null) |
62 | 0 | writer.attribute("value", label); |
63 | ||
64 | 0 | renderIdAttribute(writer, cycle); |
65 | ||
66 | 0 | renderInformalParameters(writer, cycle); |
67 | ||
68 | 0 | renderSubmitBindings(writer, cycle); |
69 | ||
70 | 0 | writer.closeTag(); |
71 | 0 | } |
72 | ||
73 | /** parameter. */ | |
74 | public abstract String getLabel(); | |
75 | ||
76 | } |