1 package org.apache.turbine.services.jsp.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21
22 import org.apache.turbine.modules.NavigationLoader;
23 import org.apache.turbine.services.template.TurbineTemplate;
24 import org.apache.turbine.util.RunData;
25
26 /***
27 * Returns output of a Navigation module. An instance of this is placed in the
28 * request by the JspLayout. This allows template authors to
29 * set the navigation template they'd like to place in their templates.<br>
30 * Here's how it's used in a JSP template:<br>
31 * <code>
32 * <%useBean id="navigation" class="JspNavigation" scope="request"/%>
33 * ...
34 * <%= navigation.setTemplate("admin_navigation.jsp") %>
35 * </code>
36 * @author <a href="john.mcnally@clearink.com">John D. McNally</a>
37 * @author <a href="mbryson@mont.mindspring.com">Dave Bryson</a>
38 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
39 * @version $Id: JspNavigation.java 264148 2005-08-29 14:21:04Z henning $
40 */
41 public class JspNavigation
42 {
43 /*** Logging */
44 private static Log log = LogFactory.getLog(JspNavigation.class);
45
46
47 private RunData data;
48
49 /***
50 * Constructor
51 *
52 * @param data
53 */
54 public JspNavigation(RunData data)
55 {
56 this.data = data;
57 }
58
59 /***
60 * builds the output of the navigation template
61 * @param template the name of the navigation template
62 */
63 public void setTemplate(String template)
64 {
65 data.getTemplateInfo().setNavigationTemplate(template);
66 String module = null;
67 try
68 {
69 module = TurbineTemplate.getNavigationName(template);
70 NavigationLoader.getInstance().exec(data, module);
71 }
72 catch (Exception e)
73 {
74 String message = "Error processing navigation template:" +
75 template + " using module: " + module;
76 log.error(message, e);
77 try
78 {
79 data.getOut().print("Error processing navigation template: "
80 + template + " using module: " + module);
81 }
82 catch (java.io.IOException ioe)
83 {
84 }
85 }
86 }
87 }