Coverage Report - org.apache.tapestry.html.Image
 
Classes in this File Line Coverage Branch Coverage Complexity
Image
0%
0/11
0%
0/4
3
 
 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.html;
 16  
 
 17  
 import org.apache.tapestry.AbstractComponent;
 18  
 import org.apache.tapestry.IAsset;
 19  
 import org.apache.tapestry.IMarkupWriter;
 20  
 import org.apache.tapestry.IRequestCycle;
 21  
 import org.apache.tapestry.Tapestry;
 22  
 
 23  
 /**
 24  
  * Used to insert an image. To create a rollover image, use the {@link Rollover}
 25  
  * class, which integrates a link with the image assets used with the button. [<a
 26  
  * href="../../../../../components/general/image.html">Component Reference</a>]
 27  
  * 
 28  
  * @author Howard Lewis Ship
 29  
  */
 30  
 
 31  0
 public abstract class Image extends AbstractComponent
 32  
 {
 33  
 
 34  
     /**
 35  
      * Renders the &lt;img&gt; element.
 36  
      */
 37  
 
 38  
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 39  
     {
 40  
         // Doesn't contain a body so no need to do anything on rewind (assumes
 41  
         // no
 42  
         // sideffects to accessor methods via bindings).
 43  
 
 44  0
         if (cycle.isRewinding()) return;
 45  
 
 46  0
         IAsset imageAsset = getImage();
 47  
 
 48  0
         if (imageAsset == null)
 49  0
             throw Tapestry.createRequiredParameterException(this, "image");
 50  
 
 51  0
         String imageURL = imageAsset.buildURL();
 52  
 
 53  0
         writer.beginEmpty("img");
 54  
 
 55  0
         writer.attribute("src", imageURL);
 56  
 
 57  0
         renderInformalParameters(writer, cycle);
 58  
 
 59  0
         writer.closeTag();
 60  0
     }
 61  
 
 62  
     public abstract IAsset getImage();
 63  
 }