Clover coverage report - Code Coverage for tapestry release 4.0.1
Coverage timestamp: Fri Mar 31 2006 09:12:14 EST
file stats: LOC: 93   Methods: 5
NCLOC: 51   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
FormComponentContributorContextImpl.java - 93.8% 80% 90.5%
coverage coverage
 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 java.util.Locale;
 18   
 19    import org.apache.hivemind.ClassResolver;
 20    import org.apache.hivemind.Resource;
 21    import org.apache.hivemind.util.ClasspathResource;
 22    import org.apache.tapestry.IForm;
 23    import org.apache.tapestry.IRequestCycle;
 24    import org.apache.tapestry.PageRenderSupport;
 25    import org.apache.tapestry.TapestryUtils;
 26   
 27    /**
 28    * Implementation of {@link org.apache.tapestry.form.FormComponentContributorContext}.
 29    *
 30    * @author Howard Lewis Ship
 31    * @since 4.0
 32    */
 33    public class FormComponentContributorContextImpl extends ValidationMessagesImpl implements
 34    FormComponentContributorContext
 35    {
 36    private final ClassResolver _resolver;
 37   
 38    private final PageRenderSupport _pageRenderSupport;
 39   
 40    private final IFormComponent _field;
 41   
 42    private final IForm _form;
 43   
 44    private final String _formId;
 45   
 46    /**
 47    * Used only for testing.
 48    */
 49   
 50  4 FormComponentContributorContextImpl(IFormComponent field)
 51    {
 52  4 super(field, Locale.ENGLISH);
 53   
 54  4 _field = field;
 55  4 _resolver = null;
 56  4 _formId = null;
 57  4 _pageRenderSupport = null;
 58  4 _form = null;
 59    }
 60   
 61  10 public FormComponentContributorContextImpl(Locale locale, IRequestCycle cycle,
 62    IFormComponent field)
 63    {
 64  10 super(field, locale);
 65   
 66  10 _field = field;
 67  10 _form = field.getForm();
 68  10 _formId = _form.getName();
 69   
 70  10 _resolver = cycle.getInfrastructure().getClassResolver();
 71   
 72  10 _pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, field);
 73    }
 74   
 75  2 public void includeClasspathScript(String path)
 76    {
 77  2 Resource resource = new ClasspathResource(_resolver, path);
 78   
 79  2 _pageRenderSupport.addExternalScript(resource);
 80    }
 81   
 82  2 public void addSubmitHandler(String submitListener)
 83    {
 84  2 _pageRenderSupport.addInitializationScript("Tapestry.onsubmit('" + _formId + "', "
 85    + submitListener + ");");
 86    }
 87   
 88  0 public void registerForFocus(int priority)
 89    {
 90  0 _form.registerForFocus(_field, priority);
 91    }
 92   
 93    }