Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 85   Methods: 1
NCLOC: 31   Classes: 1
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
Checkbox.java 0% 0% 0% 0%
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.IForm;
 18   
 import org.apache.tapestry.IMarkupWriter;
 19   
 import org.apache.tapestry.IRequestCycle;
 20   
 
 21   
 /**
 22   
  * Implements a component that manages an HTML &lt;input type=checkbox&gt; form element. [ <a
 23   
  * href="../../../../../ComponentReference/Checkbox.html">Component Reference </a>]
 24   
  * 
 25   
  * @author Howard Lewis Ship
 26   
  */
 27   
 
 28   
 public abstract class Checkbox extends AbstractFormComponent
 29   
 {
 30   
     /**
 31   
      * Renders the form elements, or responds when the form containing the element is submitted (by
 32   
      * checking {@link Form#isRewinding()}.
 33   
      * <p>
 34   
      * In traditional HTML, many checkboxes would have the same name but different values. Under
 35   
      * Tapestry, it makes more sense to have different names and a fixed value. For a checkbox, we
 36   
      * only care about whether the name appears as a request parameter.
 37   
      */
 38   
 
 39  0
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 40   
     {
 41  0
         IForm form = getForm(cycle);
 42   
 
 43  0
         if (form.wasPrerendered(writer, this))
 44  0
             return;
 45   
 
 46   
         // Used whether rewinding or not.
 47   
 
 48  0
         String name = form.getElementId(this);
 49   
 
 50  0
         if (form.isRewinding())
 51   
         {
 52  0
             String value = cycle.getParameter(name);
 53   
 
 54  0
             setSelected((value != null));
 55   
 
 56  0
             return;
 57   
         }
 58   
 
 59  0
         writer.beginEmpty("input");
 60  0
         writer.attribute("type", "checkbox");
 61   
 
 62  0
         writer.attribute("name", name);
 63   
 
 64  0
         if (isDisabled())
 65  0
             writer.attribute("disabled", "disabled");
 66   
 
 67  0
         if (isSelected())
 68  0
             writer.attribute("checked", "checked");
 69   
 
 70  0
         renderInformalParameters(writer, cycle);
 71   
 
 72  0
         writer.closeTag();
 73   
     }
 74   
 
 75   
     public abstract boolean isDisabled();
 76   
 
 77   
     /** @since 2.2 * */
 78   
 
 79   
     public abstract boolean isSelected();
 80   
 
 81   
     /** @since 2.2 * */
 82   
 
 83   
     public abstract void setSelected(boolean selected);
 84   
 
 85   
 }