Clover coverage report - Code Coverage for tapestry-contrib release 4.0-beta-10
Coverage timestamp: Sat Oct 8 2005 19:13:41 EDT
file stats: LOC: 76   Methods: 3
NCLOC: 39   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CheckboxGroup.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 java.util.Collection;
 18   
 19    import org.apache.tapestry.BaseComponent;
 20    import org.apache.tapestry.IMarkupWriter;
 21    import org.apache.tapestry.IRequestCycle;
 22    import org.apache.tapestry.PageRenderSupport;
 23    import org.apache.tapestry.TapestryUtils;
 24   
 25    /**
 26    * @author mb
 27    * @since 4.0
 28    */
 29    public abstract class CheckboxGroup extends BaseComponent
 30    {
 31    public final static String CHECKBOX_GROUP_ATTRIBUTE = "org.apache.tapestry.contrib.form.CheckboxGroup";
 32   
 33    public abstract Collection getCheckboxNames();
 34    public abstract String getFunctionName();
 35    public abstract void setFunctionName(String functionName);
 36   
 37  0 public void registerControlledCheckbox(ControlledCheckbox checkbox)
 38    {
 39  0 String name = checkbox.getCheckboxName();
 40  0 String form = checkbox.getForm().getName();
 41  0 getCheckboxNames().add(form + "." + name);
 42    }
 43   
 44    /**
 45    * @see org.apache.tapestry.BaseComponent#renderComponent(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle)
 46    */
 47  0 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 48    {
 49  0 Object objOtherGroup = cycle.getAttribute(CHECKBOX_GROUP_ATTRIBUTE);
 50  0 cycle.setAttribute(CHECKBOX_GROUP_ATTRIBUTE, this);
 51   
 52  0 initialize(cycle);
 53   
 54  0 super.renderComponent(writer, cycle);
 55   
 56    // clear the registered checkbox names after rendering
 57    // allows the component to be used in cycles
 58  0 getCheckboxNames().clear();
 59   
 60  0 cycle.setAttribute(CHECKBOX_GROUP_ATTRIBUTE, objOtherGroup);
 61    }
 62   
 63  0 private void initialize(IRequestCycle cycle)
 64    {
 65  0 String functionName = "setCheckboxGroup";
 66   
 67  0 if (!cycle.isRewinding()) {
 68  0 PageRenderSupport body = TapestryUtils.getPageRenderSupport(cycle, this);
 69  0 if (body != null)
 70  0 functionName = body.getUniqueString("setCheckboxGroup");
 71    }
 72   
 73  0 setFunctionName(functionName);
 74    }
 75   
 76    }