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