Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 74   Methods: 1
NCLOC: 24   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
RenderBlock.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.components;
 16   
 
 17   
 import org.apache.tapestry.AbstractComponent;
 18   
 import org.apache.tapestry.IComponent;
 19   
 import org.apache.tapestry.IMarkupWriter;
 20   
 import org.apache.tapestry.IRequestCycle;
 21   
 
 22   
 /**
 23   
  * Renders the text and components wrapped by a {@link Block}component. [ <a
 24   
  * href="../../../../../ComponentReference/RenderBlock.html">Component Reference </a>]
 25   
  * <p>
 26   
  * It is possible for an RenderBlock to obtain a Block from a page <em>other than</em> the render
 27   
  * page. This works, even when the Block contains links, forms and form components. The action and
 28   
  * direct services will create URLs that properly address this situation.
 29   
  * <p>
 30   
  * However, because the rendering page can't know ahead of time about these foriegn Blocks,
 31   
  * {@link org.apache.tapestry.event.PageRenderListener}methods (for components and objects of the
 32   
  * foriegn page) via RenderBlock will <em>not</em> be executed. This specifically affects the
 33   
  * methods of the {@link org.apache.tapestry.event.PageRenderListener}interface.
 34   
  * <p>
 35   
  * Before rendering its {@link Block}, RenderBlock will set itself as the Block's inserter, and
 36   
  * will reset the inserter after the {@link Block}is rendered. This gives the components contained
 37   
  * in the {@link Block}access to its inserted environment via the RenderBlock. In particular this
 38   
  * allows the contained components to access the informal parameters of the RenderBlock which
 39   
  * effectively allows parameters to be passed to the components contained in a Block.
 40   
  * 
 41   
  * @author Howard Lewis Ship
 42   
  */
 43   
 
 44   
 public abstract class RenderBlock extends AbstractComponent
 45   
 {
 46   
     /**
 47   
      * If block is not null, then the block's inserter is set (to this),
 48   
      * {@link org.apache.tapestry.IComponent#renderBody(IMarkupWriter, IRequestCycle)}is invoked on
 49   
      * it, and the Block's inserter is set back to its previous state.
 50   
      */
 51   
 
 52  3
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 53   
     {
 54  3
         Block block = getBlock();
 55   
 
 56  3
         if (block == null)
 57  1
             return;
 58   
 
 59  2
         IComponent previousInserter = block.getInserter();
 60   
 
 61  2
         try
 62   
         {
 63  2
             block.setInserter(this);
 64  2
             block.renderBody(writer, cycle);
 65   
         }
 66   
         finally
 67   
         {
 68  2
             block.setInserter(previousInserter);
 69   
         }
 70   
     }
 71   
 
 72   
     public abstract Block getBlock();
 73   
 
 74   
 }