Coverage Report - org.apache.turbine.services.jsp.util.JspNavigation
 
Classes in this File Line Coverage Branch Coverage Complexity
JspNavigation
0%
0/17
N/A
2
 
 1  
 package org.apache.turbine.services.jsp.util;
 2  
 
 3  
 
 4  
 /*
 5  
  * Licensed to the Apache Software Foundation (ASF) under one
 6  
  * or more contributor license agreements.  See the NOTICE file
 7  
  * distributed with this work for additional information
 8  
  * regarding copyright ownership.  The ASF licenses this file
 9  
  * to you under the Apache License, Version 2.0 (the
 10  
  * "License"); you may not use this file except in compliance
 11  
  * with the License.  You may obtain a copy of the License at
 12  
  *
 13  
  *   http://www.apache.org/licenses/LICENSE-2.0
 14  
  *
 15  
  * Unless required by applicable law or agreed to in writing,
 16  
  * software distributed under the License is distributed on an
 17  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 18  
  * KIND, either express or implied.  See the License for the
 19  
  * specific language governing permissions and limitations
 20  
  * under the License.
 21  
  */
 22  
 
 23  
 
 24  
 import org.apache.commons.logging.Log;
 25  
 import org.apache.commons.logging.LogFactory;
 26  
 import org.apache.turbine.modules.NavigationLoader;
 27  
 import org.apache.turbine.services.TurbineServices;
 28  
 import org.apache.turbine.services.template.TemplateService;
 29  
 import org.apache.turbine.util.RunData;
 30  
 
 31  
 /**
 32  
  * Returns output of a Navigation module. An instance of this is placed in the
 33  
  * request by the JspLayout. This allows template authors to
 34  
  * set the navigation template they'd like to place in their templates.<br>
 35  
  * Here's how it's used in a JSP template:<br>
 36  
  * <code>
 37  
  * &lt;%useBean id="navigation" class="JspNavigation" scope="request" %&gt;
 38  
  * ...
 39  
  * &lt;%= navigation.setTemplate("admin_navigation.jsp") %&gt;
 40  
  * </code>
 41  
  * @author <a href="john.mcnally@clearink.com">John D. McNally</a>
 42  
  * @author <a href="mbryson@mont.mindspring.com">Dave Bryson</a>
 43  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 44  
  * @version $Id: JspNavigation.java 1773378 2016-12-09 13:19:59Z tv $
 45  
  */
 46  
 public class JspNavigation
 47  
 {
 48  
     /** Logging */
 49  0
     private static Log log = LogFactory.getLog(JspNavigation.class);
 50  
 
 51  
     /* The RunData object */
 52  
     private final RunData data;
 53  
 
 54  
     /**
 55  
      * Constructor
 56  
      *
 57  
      * @param data Turbine request data
 58  
      */
 59  
     public JspNavigation(RunData data)
 60  0
     {
 61  0
         this.data = data;
 62  0
     }
 63  
 
 64  
     /**
 65  
      * builds the output of the navigation template
 66  
      * @param template the name of the navigation template
 67  
      */
 68  
     public void setTemplate(String template)
 69  
     {
 70  0
         data.getTemplateInfo().setNavigationTemplate(template);
 71  0
         String module = null;
 72  
         try
 73  
         {
 74  0
             TemplateService templateService = (TemplateService)TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME);
 75  0
             module = templateService.getNavigationName(template);
 76  0
             NavigationLoader.getInstance().exec(data, module);
 77  
         }
 78  0
         catch (Exception e)
 79  
         {
 80  0
             String message = "Error processing navigation template:" +
 81  
                     template + " using module: " + module;
 82  0
             log.error(message, e);
 83  
             try
 84  
             {
 85  0
                 data.getResponse().getWriter().print("Error processing navigation template: "
 86  
                         + template + " using module: " + module);
 87  
             }
 88  0
             catch (java.io.IOException ioe)
 89  
             {
 90  
                 // ignore
 91  0
             }
 92  0
         }
 93  0
     }
 94  
 }