Clover coverage report - Code Coverage for tapestry release 4.0-beta-3
Coverage timestamp: Sun Jul 24 2005 08:26:33 EDT
file stats: LOC: 103   Methods: 6
NCLOC: 58   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
FormComponentContributorContextImpl.java - 94.7% 83.3% 92%
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 String _formDOM;
 39   
 40    private final String _fieldDOM;
 41   
 42    private final PageRenderSupport _pageRenderSupport;
 43   
 44    private final IFormComponent _field;
 45   
 46    private final IForm _form;
 47   
 48    /**
 49    * Used for testing.
 50    */
 51   
 52  3 FormComponentContributorContextImpl()
 53    {
 54  3 super(Locale.ENGLISH);
 55   
 56  3 _field = null;
 57  3 _resolver = null;
 58  3 _formDOM = null;
 59  3 _fieldDOM = null;
 60  3 _pageRenderSupport = null;
 61  3 _form = null;
 62    }
 63   
 64  5 public FormComponentContributorContextImpl(Locale locale, IRequestCycle cycle,
 65    IFormComponent component)
 66    {
 67  5 super(locale);
 68   
 69  5 _field = component;
 70  5 _form = component.getForm();
 71   
 72  5 _resolver = cycle.getInfrastructure().getClassResolver();
 73   
 74  5 _formDOM = "document." + _form.getName();
 75  5 _fieldDOM = _formDOM + "." + component.getName();
 76   
 77  5 _pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, component);
 78    }
 79   
 80  1 public String getFieldDOM()
 81    {
 82  1 return _fieldDOM;
 83    }
 84   
 85  1 public void includeClasspathScript(String path)
 86    {
 87  1 Resource resource = new ClasspathResource(_resolver, path);
 88   
 89  1 _pageRenderSupport.addExternalScript(resource);
 90    }
 91   
 92  1 public void addSubmitListener(String submitListener)
 93    {
 94  1 _pageRenderSupport.addInitializationScript(_formDOM + ".events.addSubmitListener("
 95    + submitListener + ");");
 96    }
 97   
 98  0 public void registerForFocus(int priority)
 99    {
 100  0 _form.registerForFocus(_field, priority);
 101    }
 102   
 103    }