Coverage Report - org.apache.tapestry.form.TextArea
 
Classes in this File Line Coverage Branch Coverage Complexity
TextArea
0%
0/26
0%
0/4
1.429
 
 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 &lt;textarea&gt; form element. [<a
 23  
  * href="../../../../../components/form/textarea.html">Component Reference</a>]
 24  
  * <p>
 25  
  * As of 4.0, this component can be configurably translated and validated.
 26  
  *
 27  
  * @author Howard Lewis Ship
 28  
  * @author Paul Ferraro
 29  
  */
 30  0
 public abstract class TextArea extends AbstractFormComponent implements TranslatedField {
 31  
 
 32  
     public abstract Object getValue();
 33  
 
 34  
     public abstract void setValue(Object value);
 35  
 
 36  
     /**
 37  
      * @see org.apache.tapestry.form.AbstractFormComponent#renderFormComponent(org.apache.tapestry.IMarkupWriter,
 38  
      *      org.apache.tapestry.IRequestCycle)
 39  
      */
 40  
     protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
 41  
     {
 42  0
         String value = getTranslatedFieldSupport().format(this, getValue());
 43  
 
 44  0
         renderDelegatePrefix(writer, cycle);
 45  
 
 46  0
         writer.begin("textarea");
 47  
 
 48  0
         writer.attribute("name", getName());
 49  
 
 50  0
         if (isDisabled())
 51  0
             writer.attribute("disabled", "disabled");
 52  
 
 53  0
         renderIdAttribute(writer, cycle);
 54  
 
 55  0
         renderDelegateAttributes(writer, cycle);
 56  
 
 57  0
         getTranslatedFieldSupport().renderContributions(this, writer, cycle);
 58  0
         getValidatableFieldSupport().renderContributions(this, writer, cycle);
 59  
 
 60  0
         renderInformalParameters(writer, cycle);
 61  
 
 62  0
         if (value != null)
 63  0
             writer.print(value);
 64  
 
 65  0
         writer.end();
 66  
 
 67  0
         renderDelegateSuffix(writer, cycle);
 68  0
     }
 69  
 
 70  
     /**
 71  
      * @see org.apache.tapestry.form.AbstractFormComponent#rewindFormComponent(org.apache.tapestry.IMarkupWriter,
 72  
      *      org.apache.tapestry.IRequestCycle)
 73  
      */
 74  
     protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
 75  
     {
 76  0
         String value = cycle.getParameter(getName());
 77  
 
 78  
         try
 79  
         {
 80  0
             String text = (String) getTranslatedFieldSupport().parse(this, value);
 81  
 
 82  0
             getValidatableFieldSupport().validate(this, writer, cycle, text);
 83  
 
 84  0
             setValue(text);
 85  
         }
 86  0
         catch (ValidatorException e)
 87  
         {
 88  0
             getForm().getDelegate().record(e);
 89  0
         }
 90  0
     }
 91  
 
 92  
     /**
 93  
      * Injected.
 94  
      */
 95  
     public abstract ValidatableFieldSupport getValidatableFieldSupport();
 96  
 
 97  
     /**
 98  
      * Injected.
 99  
      */
 100  
     public abstract TranslatedFieldSupport getTranslatedFieldSupport();
 101  
 
 102  
     /**
 103  
      * @see org.apache.tapestry.form.AbstractFormComponent#isRequired()
 104  
      */
 105  
     public boolean isRequired()
 106  
     {
 107  0
         return getValidatableFieldSupport().isRequired(this);
 108  
     }
 109  
 }