KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > services > jsp > util > JspScreenPlaceholder


1 package org.apache.turbine.services.jsp.util;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21
22 import org.apache.turbine.modules.ScreenLoader;
23 import org.apache.turbine.services.template.TurbineTemplate;
24 import org.apache.turbine.util.RunData;
25
26 /**
27  * Returns output of a Screen module. An instance of this is placed in the
28  * request by the JspLayout. This allows template authors to
29  * place the screen template within the layout.<br>
30  * Here's how it's used in a JSP template:<br>
31  * <code>
32  * <%useBean id="screen_placeholder" class="JspScreenPlaceholder" scope="request"/%>
33  * ...
34  * <%= screen_placeholder %>
35  *</code>
36  *
37  * @author <a HREF="john.mcnally@clearink.com">John D. McNally</a>
38  * @author <a HREF="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
39  * @version $Id: JspScreenPlaceholder.java,v 1.6.2.2 2004/05/20 03:06:51 seade Exp $
40  */

41 public class JspScreenPlaceholder
42 {
43     /** Logging */
44     private static Log log = LogFactory.getLog(JspNavigation.class);
45
46     /* The RunData object */
47     private RunData data;
48
49     /**
50      * Constructor
51      *
52      * @param data A Rundata Object
53      */

54     public JspScreenPlaceholder(RunData data)
55     {
56         this.data = data;
57     }
58
59     /**
60      * builds the output of the navigation template
61      */

62     public void exec()
63     {
64         String JavaDoc template = null;
65         String JavaDoc module = null;
66         try
67         {
68             template = data.getTemplateInfo().getScreenTemplate();
69             module = TurbineTemplate.getScreenName(template);
70             ScreenLoader.getInstance().exec(data, module);
71         }
72         catch (Exception JavaDoc e)
73         {
74             String JavaDoc 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 JavaDoc ioe)
83             {
84             }
85         }
86     }
87 }
88
Popular Tags