Clover coverage report - Code Coverage for tapestry release 4.0-beta-2
Coverage timestamp: Sat Jul 9 2005 22:02:17 EDT
file stats: LOC: 90   Methods: 5
NCLOC: 49   Classes: 1
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
FormComponentContributorContextImpl.java - 100% 100% 100%
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    /**
 45    * Used for testing.
 46    */
 47   
 48  3 FormComponentContributorContextImpl()
 49    {
 50  3 super(Locale.ENGLISH);
 51   
 52  3 _resolver = null;
 53  3 _formDOM = null;
 54  3 _fieldDOM = null;
 55  3 _pageRenderSupport = null;
 56    }
 57   
 58  5 public FormComponentContributorContextImpl(Locale locale, IRequestCycle cycle,
 59    IFormComponent component)
 60    {
 61  5 super(locale);
 62   
 63  5 IForm form = component.getForm();
 64   
 65  5 _resolver = cycle.getInfrastructure().getClassResolver();
 66   
 67  5 _formDOM = "document." + form.getName();
 68  5 _fieldDOM = _formDOM + "." + component.getName();
 69   
 70  5 _pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, component);
 71    }
 72   
 73  1 public String getFieldDOM()
 74    {
 75  1 return _fieldDOM;
 76    }
 77   
 78  1 public void includeClasspathScript(String path)
 79    {
 80  1 Resource resource = new ClasspathResource(_resolver, path);
 81   
 82  1 _pageRenderSupport.addExternalScript(resource);
 83    }
 84   
 85  1 public void addSubmitListener(String submitListener)
 86    {
 87  1 _pageRenderSupport.addInitializationScript(_formDOM + ".events.addSubmitListener("
 88    + submitListener + ");");
 89    }
 90    }