##### Coverage Report - org.apache.turbine.services.jsp.util.JspNavigation

Classes in this File | Line Coverage | Branch Coverage | Complexity
JspNavigation |
0% | 0/16
N/A | N/A
| 2.0;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.template.TurbineTemplate;
28 |  |
     import org.apache.turbine.util.RunData;
29 |  |
30 |  |
     /**
31 |  |
      * Returns output of a Navigation module. An instance of this is placed in the
32 |  |
      * request by the JspLayout. This allows template authors to
33 |  |
      * set the navigation template they'd like to place in their templates.<br>
34 |  |
      * Here's how it's used in a JSP template:<br>
35 |  |
      * <code>
36 |  |
      * <%useBean id="navigation" class="JspNavigation" scope="request"/%>
37 |  |
      * ...
38 |  |
      * <%= navigation.setTemplate("admin_navigation.jsp") %>
39 |  |
      * </code>
40 |  |
      * @author <a href="john.mcnally@clearink.com">John D. McNally</a>
41 |  |
      * @author <a href="mbryson@mont.mindspring.com">Dave Bryson</a>
42 |  |
      * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
43 |  |
      * @version $Id: JspNavigation.java 1078552 2011-03-06 19:58:46Z tv $
44 |  |
      */
45 |  |
     public class JspNavigation
46 |  |
     {
47 |  |
         /** Logging */
48 | 0 |
         private static Log log = LogFactory.getLog(JspNavigation.class);
49 |  |
50 |  |
         /* The RunData object */
51 |  |
         private final RunData data;
52 |  |
53 |  |
         /**
54 |  |
          * Constructor
55 |  |
          *
56 |  |
          * @param data
57 |  |
          */
58 |  |
         public JspNavigation(RunData data)
59 | 0 |
         {
60 | 0 |
             this.data = data;
61 | 0 |
         }
62 |  |
63 |  |
         /**
64 |  |
          * builds the output of the navigation template
65 |  |
          * @param template the name of the navigation template
66 |  |
          */
67 |  |
         public void setTemplate(String template)
68 |  |
         {
69 | 0 |
             data.getTemplateInfo().setNavigationTemplate(template);
70 | 0 |
             String module = null;
71 |  |
             try
72 |  |
             {
73 | 0 |
                 module = TurbineTemplate.getNavigationName(template);
74 | 0 |
                 NavigationLoader.getInstance().exec(data, module);
75 |  |
             }
76 | 0 |
             catch (Exception e)
77 |  |
             {
78 | 0 |
                 String message = "Error processing navigation template:" +
79 |  |
                         template + " using module: " + module;
80 | 0 |
                 log.error(message, e);
81 |  |
                 try
82 |  |
                 {
83 | 0 |
                     data.getResponse().getWriter().print("Error processing navigation template: "
84 |  |
                             + template + " using module: " + module);
85 |  |
                 }
86 | 0 |
                 catch (java.io.IOException ioe)
87 |  |
                 {
88 |  |
                     // ignore
89 | 0 |
                 }
90 | 0 |
             }
91 | 0 |
         }
92 |  |
     }