Clover coverage report - Code Coverage for tapestry release 4.0-beta-10
Coverage timestamp: Sat Oct 8 2005 19:08:05 EDT
file stats: LOC: 73   Methods: 2
NCLOC: 24   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Submit.java 100% 100% 100% 100%
coverage
 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 &lt;input type=submit&gt; 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    /**
 46    * @see org.apache.tapestry.form.AbstractFormComponent#renderFormComponent(org.apache.tapestry.IMarkupWriter,
 47    * org.apache.tapestry.IRequestCycle)
 48    */
 49  3 protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
 50    {
 51  3 writer.beginEmpty("input");
 52  3 writer.attribute("type", "submit");
 53  3 writer.attribute("name", getName());
 54   
 55  3 if (isDisabled())
 56  1 writer.attribute("disabled", "disabled");
 57   
 58  3 String label = getLabel();
 59   
 60  3 if (label != null)
 61  1 writer.attribute("value", label);
 62   
 63  3 renderIdAttribute(writer, cycle);
 64   
 65  3 renderInformalParameters(writer, cycle);
 66   
 67  3 writer.closeTag();
 68    }
 69   
 70    /** parameter */
 71    public abstract String getLabel();
 72   
 73    }