Clover coverage report - Code Coverage for tapestry-contrib release 4.0.1
Coverage timestamp: Fri Mar 31 2006 09:15:40 EST
file stats: LOC: 74   Methods: 5
NCLOC: 43   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ControlledCheckbox.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.contrib.form.checkboxes;
 16   
 17    import org.apache.hivemind.ApplicationRuntimeException;
 18    import org.apache.tapestry.BaseComponent;
 19    import org.apache.tapestry.IForm;
 20    import org.apache.tapestry.IMarkupWriter;
 21    import org.apache.tapestry.IRequestCycle;
 22    import org.apache.tapestry.form.Checkbox;
 23   
 24    /**
 25    * @author mb
 26    * @since 4.0
 27    */
 28    public abstract class ControlledCheckbox extends BaseComponent
 29    {
 30    public abstract CheckboxGroup getGroup();
 31   
 32  0 public String getCheckboxName()
 33    {
 34  0 Checkbox checkbox = (Checkbox) getComponent("checkbox");
 35  0 String name = checkbox.getName();
 36  0 return name;
 37    }
 38   
 39  0 public IForm getForm()
 40    {
 41  0 Checkbox checkbox = (Checkbox) getComponent("checkbox");
 42  0 IForm form = checkbox.getForm();
 43  0 return form;
 44    }
 45   
 46    /**
 47    * @see org.apache.tapestry.BaseComponent#renderComponent(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle)
 48    */
 49  0 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 50    {
 51  0 super.renderComponent(writer, cycle);
 52   
 53  0 registerCheckbox();
 54    }
 55   
 56  0 protected void registerCheckbox()
 57    {
 58  0 getCheckboxGroup().registerControlledCheckbox(this);
 59    }
 60   
 61  0 public CheckboxGroup getCheckboxGroup()
 62    {
 63  0 CheckboxGroup group = getGroup();
 64  0 if (group == null) {
 65  0 IRequestCycle cycle = getPage().getRequestCycle();
 66  0 group = (CheckboxGroup) cycle.getAttribute(CheckboxGroup.CHECKBOX_GROUP_ATTRIBUTE);
 67    }
 68  0 if (group == null)
 69  0 throw new ApplicationRuntimeException("The component " + getExtendedId() + " must be wrapped by a CheckboxGroup or the 'group' parameter must be set.");
 70   
 71  0 return group;
 72    }
 73   
 74    }