Clover coverage report - Code Coverage for tapestry release 3.1-alpha-1
Coverage timestamp: Mon Feb 21 2005 09:16:14 EST
file stats: LOC: 71   Methods: 1
NCLOC: 27   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
Upload.java 100% 100% 100% 100%
coverage
 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.IForm;
 18   
 import org.apache.tapestry.IMarkupWriter;
 19   
 import org.apache.tapestry.IRequestCycle;
 20   
 import org.apache.tapestry.request.IUploadFile;
 21   
 
 22   
 /**
 23   
  *  Form element used to upload files.  For the momement, it is necessary to
 24   
  *  explicitly set the form's enctype to "multipart/form-data".
 25   
  * 
 26   
  *  [<a href="../../../../../ComponentReference/Upload.html">Component Reference</a>]
 27   
  * 
 28   
  *  @author Howard Lewis Ship
 29   
  *  @since 1.0.8
 30   
  * 
 31   
  **/
 32   
 
 33   
 public abstract class Upload extends AbstractFormComponent
 34   
 {
 35  6
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 36   
     {
 37  6
         IForm form = getForm(cycle);
 38   
         
 39  6
         String name = form.getElementId(this);
 40   
 
 41  6
         if (form.isRewinding())
 42   
         {
 43  4
             if (!isDisabled())
 44  3
                 setFile(cycle.getRequestContext().getUploadFile(name));
 45   
 
 46  4
             return;
 47   
         }
 48   
 
 49   
         // Force the form to use the correct encoding type for
 50   
         // file uploads.
 51   
         
 52  2
         form.setEncodingType("multipart/form-data");
 53   
 
 54  2
         writer.beginEmpty("input");
 55  2
         writer.attribute("type", "file");
 56  2
         writer.attribute("name", name);
 57   
 
 58  2
         if (isDisabled())
 59  1
             writer.attribute("disabled", "disabled");
 60   
 
 61   
         // Size, width, etc. can be specified as informal parameters
 62   
         // (Not making the same mistake here that was made with TextField
 63   
         // and friends).
 64   
 
 65  2
         renderInformalParameters(writer, cycle);
 66   
     }
 67   
 
 68   
     public abstract boolean isDisabled();
 69   
 
 70   
     public abstract void setFile(IUploadFile file);
 71   
 }