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