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