Coverage report

  %line %branch
org.apache.turbine.modules.layouts.VelocityECSLayout
0% 
0% 

 1  
 package org.apache.turbine.modules.layouts;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License")
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import org.apache.commons.logging.Log;
 20  
 import org.apache.commons.logging.LogFactory;
 21  
 
 22  
 import org.apache.ecs.ConcreteElement;
 23  
 
 24  
 import org.apache.turbine.TurbineConstants;
 25  
 import org.apache.turbine.modules.Layout;
 26  
 import org.apache.turbine.modules.ScreenLoader;
 27  
 import org.apache.turbine.services.velocity.TurbineVelocity;
 28  
 import org.apache.turbine.util.RunData;
 29  
 import org.apache.turbine.util.template.TemplateNavigation;
 30  
 
 31  
 import org.apache.velocity.context.Context;
 32  
 
 33  
 /**
 34  
  * This Layout module allows Velocity templates to be used as layouts.
 35  
  * Since dynamic content is supposed to be primarily located in
 36  
  * screens and navigations there should be relatively few reasons to
 37  
  * subclass this Layout.
 38  
  *
 39  
  * This class uses ECS to render the layout.
 40  
  *
 41  
  * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
 42  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 43  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 44  
  * @version $Id: VelocityECSLayout.java 264148 2005-08-29 14:21:04Z henning $
 45  
  * @deprecated you should use VelocityOnlyLayout
 46  
  */
 47  
 public class VelocityECSLayout
 48  
     extends Layout
 49  
 {
 50  
     /** Logging */
 51  0
     private static Log log = LogFactory.getLog(VelocityECSLayout.class);
 52  
 
 53  
     /** The prefix for lookup up layout pages */
 54  0
     private String prefix = TurbineConstants.LAYOUT_PREFIX + "/";
 55  
 
 56  
     /** Warn only once */
 57  0
     private static boolean hasWarned = false;
 58  
 
 59  
     /**
 60  
      * C'tor warns once about deprecation.
 61  
      */
 62  
     public VelocityECSLayout()
 63  0
     {
 64  0
         if (!hasWarned)
 65  
         {
 66  0
             log.warn("The VelocityECSLayout is deprecated. "
 67  
                      + "Please switch to VelocityOnlyLayout.");
 68  0
             hasWarned = true;
 69  
         }
 70  0
     }
 71  
 
 72  
     /**
 73  
      * Build the layout.  Also sets the ContentType and Locale headers
 74  
      * of the HttpServletResponse object.
 75  
      *
 76  
      * @param data Turbine information.
 77  
      * @exception Exception a generic exception.
 78  
      */
 79  
     public void doBuild(RunData data)
 80  
         throws Exception
 81  
     {
 82  
         // Get the context needed by Velocity.
 83  0
         Context context = TurbineVelocity.getContext(data);
 84  
 
 85  0
         String screenName = data.getScreen();
 86  
 
 87  0
         log.debug("Loading Screen " + screenName);
 88  
 
 89  
         // First, generate the screen and put it in the context so
 90  
         // we can grab it the layout template.
 91  0
         ConcreteElement results =
 92  
             ScreenLoader.getInstance().eval(data, screenName);
 93  
 
 94  0
         String returnValue = (results == null) ? "" : results.toString();
 95  
 
 96  
         // variable for the screen in the layout template
 97  0
         context.put(TurbineConstants.SCREEN_PLACEHOLDER, returnValue);
 98  
 
 99  
         // variable to reference the navigation screen in the layout template
 100  0
         context.put(TurbineConstants.NAVIGATION_PLACEHOLDER,
 101  
                     new TemplateNavigation(data));
 102  
 
 103  
         // Grab the layout template set in the VelocityPage.
 104  
         // If null, then use the default layout template
 105  
         // (done by the TemplateInfo object)
 106  0
         String templateName = data.getTemplateInfo().getLayoutTemplate();
 107  
 
 108  0
         log.debug("Now trying to render layout " + templateName);
 109  
 
 110  
         // Finally, generate the layout template and add it to the body of the
 111  
         // Document in the RunData.
 112  0
         data.getPage().getBody().addElement(TurbineVelocity
 113  
                 .handleRequest(context, prefix +  templateName));
 114  0
     }
 115  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.