Coverage Report - org.apache.tapestry.form.TranslatedFieldSupportImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
TranslatedFieldSupportImpl
0%
0/14
0%
0/4
1.4
 
 1  
 // Copyright 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.hivemind.service.ThreadLocale;
 18  
 import org.apache.tapestry.IMarkupWriter;
 19  
 import org.apache.tapestry.IRequestCycle;
 20  
 import org.apache.tapestry.valid.IValidationDelegate;
 21  
 import org.apache.tapestry.valid.ValidatorException;
 22  
 
 23  
 /**
 24  
  * 
 25  
  * @author unknown
 26  
  */
 27  0
 public class TranslatedFieldSupportImpl implements TranslatedFieldSupport
 28  
 {
 29  
     private ThreadLocale _threadLocale;
 30  
 
 31  
     /**
 32  
      * @return Returns the threadLocale.
 33  
      */
 34  
     public ThreadLocale getThreadLocale()
 35  
     {
 36  0
         return _threadLocale;
 37  
     }
 38  
 
 39  
     /**
 40  
      * @param threadLocale
 41  
      *            The threadLocale to set.
 42  
      */
 43  
     public void setThreadLocale(ThreadLocale threadLocale)
 44  
     {
 45  0
         _threadLocale = threadLocale;
 46  0
     }
 47  
 
 48  
     public String format(TranslatedField field, Object object)
 49  
     {
 50  0
         IValidationDelegate delegate = field.getForm().getDelegate();
 51  
 
 52  0
         return delegate.isInError() ? delegate.getFieldInputValue() : field.getTranslator().format(
 53  
                 field,
 54  
                 _threadLocale.getLocale(),
 55  
                 object);
 56  
     }
 57  
 
 58  
     public Object parse(TranslatedField field, String text) throws ValidatorException
 59  
     {
 60  0
         IValidationDelegate delegate = field.getForm().getDelegate();
 61  
 
 62  0
         delegate.recordFieldInputValue(text);
 63  
 
 64  0
         ValidationMessages messages = new ValidationMessagesImpl(field, _threadLocale.getLocale());
 65  
 
 66  0
         return field.getTranslator().parse(field, messages, text);
 67  
     }
 68  
 
 69  
     public void renderContributions(TranslatedField field, IMarkupWriter writer, IRequestCycle cycle)
 70  
     {
 71  0
         if (field.getForm().isClientValidationEnabled())
 72  
         {
 73  0
             FormComponentContributorContext context = new FormComponentContributorContextImpl(
 74  
                     _threadLocale.getLocale(), cycle, field);
 75  
 
 76  0
             field.getTranslator().renderContribution(writer, cycle, context, field);
 77  
         }
 78  0
     }
 79  
 }