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.ScreenLoader;
26: import org.apache.turbine.services.template.TurbineTemplate;
27: import org.apache.turbine.util.RunData;
28:
29: /**
30: * Returns output of a Screen module. An instance of this is placed in the
31: * request by the JspLayout. This allows template authors to
32: * place the screen template within the layout.<br>
33: * Here's how it's used in a JSP template:<br>
34: * <code>
35: * <%useBean id="screen_placeholder" class="JspScreenPlaceholder" scope="request"/%>
36: * ...
37: * <%= screen_placeholder %>
38: *</code>
39: *
40: * @author <a href="john.mcnally@clearink.com">John D. McNally</a>
41: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
42: * @version $Id: JspScreenPlaceholder.java 534527 2007-05-02 16:10:59Z tv $
43: */
44: public class JspScreenPlaceholder {
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 A Rundata Object
55: */
56: public JspScreenPlaceholder(RunData data) {
57: this .data = data;
58: }
59:
60: /**
61: * builds the output of the navigation template
62: */
63: public void exec() {
64: String template = null;
65: String module = null;
66: try {
67: template = data.getTemplateInfo().getScreenTemplate();
68: module = TurbineTemplate.getScreenName(template);
69: ScreenLoader.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: }
|