Clover coverage report - Code Coverage for tapestry release 4.0.1
Coverage timestamp: Fri Mar 31 2006 09:12:14 EST
file stats: LOC: 108   Methods: 3
NCLOC: 46   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TextArea.java 75% 95.5% 66.7% 89.7%
coverage 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    import org.apache.tapestry.valid.ValidatorException;
 20   
 21    /**
 22    * Implements a component that manages an HTML <textarea> form element.
 23    *
 24    * [<a href="../../../../../ComponentReference/TextArea.html">Component Reference</a>]
 25    * <p>
 26    * As of 4.0, this component can be configurably translated and validated.
 27    *
 28    * @author Howard Lewis Ship
 29    * @author Paul Ferraro
 30    */
 31    public abstract class TextArea extends AbstractFormComponent implements TranslatedField
 32    {
 33    public abstract String getValue();
 34   
 35    public abstract void setValue(String value);
 36   
 37    /**
 38    * @see org.apache.tapestry.form.AbstractFormComponent#renderFormComponent(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle)
 39    */
 40  8 protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
 41    {
 42  8 String value = getTranslatedFieldSupport().format(this, getValue());
 43   
 44  8 renderDelegatePrefix(writer, cycle);
 45   
 46  8 writer.begin("textarea");
 47   
 48  8 writer.attribute("name", getName());
 49   
 50  8 if (isDisabled())
 51  2 writer.attribute("disabled", "disabled");
 52   
 53  8 renderIdAttribute(writer, cycle);
 54   
 55  8 renderDelegateAttributes(writer, cycle);
 56   
 57  8 getTranslatedFieldSupport().renderContributions(this, writer, cycle);
 58  8 getValidatableFieldSupport().renderContributions(this, writer, cycle);
 59   
 60  8 renderInformalParameters(writer, cycle);
 61   
 62  8 if (value != null)
 63  8 writer.print(value);
 64   
 65  8 writer.end();
 66   
 67  8 renderDelegateSuffix(writer, cycle);
 68    }
 69   
 70    /**
 71    * @see org.apache.tapestry.form.AbstractFormComponent#rewindFormComponent(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle)
 72    */
 73  6 protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
 74    {
 75  6 String value = cycle.getParameter(getName());
 76   
 77  6 try
 78    {
 79  6 String text = (String) getTranslatedFieldSupport().parse(this, value);
 80   
 81  4 getValidatableFieldSupport().validate(this, writer, cycle, text);
 82   
 83  2 setValue(text);
 84    }
 85    catch (ValidatorException e)
 86    {
 87  4 getForm().getDelegate().record(e);
 88    }
 89    }
 90   
 91    /**
 92    * Injected.
 93    */
 94    public abstract ValidatableFieldSupport getValidatableFieldSupport();
 95   
 96    /**
 97    * Injected.
 98    */
 99    public abstract TranslatedFieldSupport getTranslatedFieldSupport();
 100   
 101    /**
 102    * @see org.apache.tapestry.form.AbstractFormComponent#isRequired()
 103    */
 104  0 public boolean isRequired()
 105    {
 106  0 return getValidatableFieldSupport().isRequired(this);
 107    }
 108    }