01: package org.apache.turbine.services.jsp.util;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
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: /** Logging */
46: private static Log log = LogFactory.getLog(JspNavigation.class);
47:
48: /* The RunData object */
49: private RunData data;
50:
51: /**
52: * Constructor
53: *
54: * @param data
55: */
56: public JspNavigation(RunData data) {
57: this .data = data;
58: }
59:
60: /**
61: * builds the output of the navigation template
62: * @param template the name of the navigation template
63: */
64: public void setTemplate(String template) {
65: data.getTemplateInfo().setNavigationTemplate(template);
66: String module = null;
67: try {
68: module = TurbineTemplate.getNavigationName(template);
69: NavigationLoader.getInstance().exec(data, module);
70: } catch (Exception e) {
71: String message = "Error processing navigation template:"
72: + template + " using module: " + module;
73: log.error(message, e);
74: try {
75: data.getOut()
76: .print(
77: "Error processing navigation template: "
78: + template + " using module: "
79: + module);
80: } catch (java.io.IOException ioe) {
81: }
82: }
83: }
84: }
|