|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Submit.java | 100% | 100% | 100% | 100% |
|
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="../../../../../ComponentReference/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 |
public abstract class Submit extends AbstractSubmit |
|
32 |
{ |
|
33 | 2 |
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 | 2 |
return cycle.getParameter(name) != null; |
43 |
} |
|
44 |
|
|
45 | 3 |
protected void writeTag(IMarkupWriter writer, IRequestCycle cycle, String name) { |
46 | 3 |
writer.beginEmpty("input");
|
47 | 3 |
writer.attribute("type", "submit"); |
48 | 3 |
writer.attribute("name", name);
|
49 |
|
|
50 | 3 |
if (isDisabled())
|
51 | 1 |
writer.attribute("disabled", "disabled"); |
52 |
|
|
53 | 3 |
String label = getLabel(); |
54 |
|
|
55 | 3 |
if (label != null) |
56 | 1 |
writer.attribute("value", label);
|
57 |
|
|
58 | 3 |
renderInformalParameters(writer, cycle); |
59 |
|
|
60 | 3 |
writer.closeTag(); |
61 |
} |
|
62 |
|
|
63 |
/** parameter */
|
|
64 |
public abstract String getLabel();
|
|
65 |
|
|
66 |
} |
|