|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| Button.java | 75% | 73.3% | 40% | 66.7% |
|
||||||||||||||
| 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=button> form element. [ <a | |
| 22 | * href="../../../../../ComponentReference/Button.html">Component Reference </a>] | |
| 23 | * <p> | |
| 24 | * This component is useful for attaching JavaScript onclick event handlers. | |
| 25 | * | |
| 26 | * @author Howard Lewis Ship | |
| 27 | * @author Paul Geerts | |
| 28 | * @author Malcolm Edgar | |
| 29 | * @author Paul Ferraro | |
| 30 | */ | |
| 31 | public abstract class Button extends AbstractFormComponent | |
| 32 | { | |
| 33 | /** | |
| 34 | * @see org.apache.tapestry.form.AbstractFormComponent#renderFormComponent(org.apache.tapestry.IMarkupWriter, | |
| 35 | * org.apache.tapestry.IRequestCycle) | |
| 36 | */ | |
| 37 | 12 | protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle) |
| 38 | { | |
| 39 | 12 | writer.begin("button"); |
| 40 | 12 | writer.attribute("type", "button"); |
| 41 | 12 | writer.attribute("name", getName()); |
| 42 | ||
| 43 | 12 | if (isDisabled()) |
| 44 | { | |
| 45 | 0 | writer.attribute("disabled", "disabled"); |
| 46 | } | |
| 47 | ||
| 48 | 12 | renderIdAttribute(writer, cycle); |
| 49 | ||
| 50 | 12 | renderInformalParameters(writer, cycle); |
| 51 | ||
| 52 | 12 | String label = getLabel(); |
| 53 | ||
| 54 | 12 | if (label != null) |
| 55 | 3 | writer.print(label); |
| 56 | else | |
| 57 | 9 | renderBody(writer, cycle); |
| 58 | ||
| 59 | 12 | writer.end(); |
| 60 | } | |
| 61 | ||
| 62 | /** | |
| 63 | * @see org.apache.tapestry.form.AbstractFormComponent#rewindFormComponent(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle) | |
| 64 | */ | |
| 65 | 3 | protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle) |
| 66 | { | |
| 67 | // Do nothing | |
| 68 | } | |
| 69 | ||
| 70 | /** | |
| 71 | * @see org.apache.tapestry.form.IFormComponent#getClientId() | |
| 72 | */ | |
| 73 | 0 | public String getClientId() |
| 74 | { | |
| 75 | 0 | return null; |
| 76 | } | |
| 77 | ||
| 78 | /** | |
| 79 | * @see org.apache.tapestry.form.IFormComponent#getDisplayName() | |
| 80 | */ | |
| 81 | 0 | public String getDisplayName() |
| 82 | { | |
| 83 | 0 | return null; |
| 84 | } | |
| 85 | ||
| 86 | /** | |
| 87 | * @see org.apache.tapestry.form.IFormComponent#isDisabled() | |
| 88 | */ | |
| 89 | 0 | public boolean isDisabled() |
| 90 | { | |
| 91 | 0 | return false; |
| 92 | } | |
| 93 | ||
| 94 | public abstract String getLabel(); | |
| 95 | } |
|
||||||||||