Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
JspScreenPlaceholder |
|
| 2.0;2 |
1 | package org.apache.turbine.services.jsp.util; | |
2 | ||
3 | ||
4 | /* | |
5 | * Licensed to the Apache Software Foundation (ASF) under one | |
6 | * or more contributor license agreements. See the NOTICE file | |
7 | * distributed with this work for additional information | |
8 | * regarding copyright ownership. The ASF licenses this file | |
9 | * to you under the Apache License, Version 2.0 (the | |
10 | * "License"); you may not use this file except in compliance | |
11 | * with the License. You may obtain a copy of the License at | |
12 | * | |
13 | * http://www.apache.org/licenses/LICENSE-2.0 | |
14 | * | |
15 | * Unless required by applicable law or agreed to in writing, | |
16 | * software distributed under the License is distributed on an | |
17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
18 | * KIND, either express or implied. See the License for the | |
19 | * specific language governing permissions and limitations | |
20 | * under the License. | |
21 | */ | |
22 | ||
23 | ||
24 | import org.apache.commons.logging.Log; | |
25 | import org.apache.commons.logging.LogFactory; | |
26 | import org.apache.turbine.modules.Screen; | |
27 | import org.apache.turbine.modules.ScreenLoader; | |
28 | import org.apache.turbine.services.TurbineServices; | |
29 | import org.apache.turbine.services.assemblerbroker.AssemblerBrokerService; | |
30 | import org.apache.turbine.services.template.TemplateService; | |
31 | import org.apache.turbine.util.RunData; | |
32 | ||
33 | /** | |
34 | * Returns output of a Screen module. An instance of this is placed in the | |
35 | * request by the JspLayout. This allows template authors to | |
36 | * place the screen template within the layout.<br> | |
37 | * Here's how it's used in a JSP template:<br> | |
38 | * <code> | |
39 | * <%useBean id="screen_placeholder" class="JspScreenPlaceholder" scope="request" %> | |
40 | * ... | |
41 | * <%= screen_placeholder %> | |
42 | * </code> | |
43 | * | |
44 | * @author <a href="john.mcnally@clearink.com">John D. McNally</a> | |
45 | * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> | |
46 | * @version $Id: JspScreenPlaceholder.java 1773378 2016-12-09 13:19:59Z tv $ | |
47 | */ | |
48 | public class JspScreenPlaceholder | |
49 | { | |
50 | /** Logging */ | |
51 | 0 | private static Log log = LogFactory.getLog(JspNavigation.class); |
52 | ||
53 | /* The RunData object */ | |
54 | private final RunData data; | |
55 | ||
56 | private final ScreenLoader screenLoader; | |
57 | ||
58 | /** | |
59 | * Constructor | |
60 | * | |
61 | * @param data A Rundata Object | |
62 | */ | |
63 | public JspScreenPlaceholder(RunData data) | |
64 | 0 | { |
65 | 0 | this.data = data; |
66 | 0 | AssemblerBrokerService abs = (AssemblerBrokerService)TurbineServices.getInstance() |
67 | .getService(AssemblerBrokerService.SERVICE_NAME); | |
68 | 0 | this.screenLoader = (ScreenLoader)abs.getLoader(Screen.class); |
69 | 0 | } |
70 | ||
71 | /** | |
72 | * builds the output of the navigation template | |
73 | */ | |
74 | public void exec() | |
75 | { | |
76 | 0 | String template = null; |
77 | 0 | String module = null; |
78 | try | |
79 | { | |
80 | 0 | template = data.getTemplateInfo().getScreenTemplate(); |
81 | 0 | TemplateService templateService = (TemplateService)TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME); |
82 | 0 | module = templateService.getScreenName(template); |
83 | 0 | screenLoader.exec(data, module); |
84 | } | |
85 | 0 | catch (Exception e) |
86 | { | |
87 | 0 | String message = "Error processing navigation template:" + |
88 | template + " using module: " + module; | |
89 | 0 | log.error(message, e); |
90 | try | |
91 | { | |
92 | 0 | data.getResponse().getWriter().print("Error processing navigation template: " |
93 | + template + " using module: " + module); | |
94 | } | |
95 | 0 | catch (java.io.IOException ioe) |
96 | { | |
97 | // ignore | |
98 | 0 | } |
99 | 0 | } |
100 | 0 | } |
101 | } |