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