1packageorg.apache.jetspeed.services.jsp.tags;
23/*4 * Copyright 2000-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 at9 * 10 * http://www.apache.org/licenses/LICENSE-2.011 * 12 * Unless required by applicable law or agreed to in writing, software13 * 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 and16 * limitations under the License.17 */1819//import java.util.*;20import javax.servlet.jsp.JspException;
21import javax.servlet.jsp.PageContext;
22import javax.servlet.jsp.tagext.TagSupport;
2324// Turbine Classes 25import org.apache.turbine.services.jsp.JspService;
2627import org.apache.ecs.ConcreteElement;
2829// Jetspeed classes30import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
31import org.apache.jetspeed.services.logging.JetspeedLogger;
32import org.apache.jetspeed.services.resources.JetspeedResources;
33import org.apache.jetspeed.services.rundata.JetspeedRunData;
34import org.apache.jetspeed.util.template.JetspeedTool;
3536/***37 * Supporting class for the pane tag.38 * Builds the output of a PSML config file and insert it within the 39 * current JSP page40 *41 * @author <a href="mailto:raphael@apache.org">Raphaël Luta</a>42 * @author <a href="mailto:morciuch@apache.org">Mark Orciuch</a> 43 * @version $Id: JetspeedPaneTag.java,v 1.6 2004/02/23 03:59:40 jford Exp $44 */45publicclassJetspeedPaneTagextends TagSupport
46 {
47/***48 * Static initialization of the logger for this class49 */50privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(JetspeedPaneTag.class.getName());
5152private String name = null;
5354publicvoid setName(String name)
55 {
56this.name = name;
57 }
5859public String getName()
60 {
61returnthis.name;
62 }
6364/***65 * Method called when the tag is encountered to send attributes to the66 * output stream67 *68 * @return SKIP_BODY, as it is intended to be a single tag.69 */70publicint doStartTag() throws JspException
71 {
72JetspeedRunData data = (JetspeedRunData) pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
7374// retrieve the name attribute val75if (this.name == null)
76 {
77this.name = JetspeedResources.getString("screen.homepage");
78 }
7980try81 {
82 pageContext.getOut().flush();
8384 ConcreteElement result = new ConcreteElement();
8586if (data != null && data.getUser() != null)
87 {
88JetspeedTool jt = newJetspeedTool(data);
89 String jspeid = (String) data.getUser().getTemp("js_peid");
90if (jspeid != null)
91 {
92 data.setMode(JetspeedRunData.MAXIMIZE);
93 result = jt.getPortletById(jspeid);
94 }
95else96 {
97 result = jt.getPane(this.name);
98 }
99 }
100101// Check whether this is an "old" screen (that returns a ConcreteElement)102// or a "new" one that returns null.103if (result != null)
104 {
105//The ECS element must serialize in the character encoding106// of the response107 result.setCodeSet(data.getResponse().getCharacterEncoding());
108109 result.output(data.getResponse().getWriter());
110 }
111112 }
113catch (Exception e)
114 {
115 String message = "Error processing name '" + name + "'.";
116 logger.error(message, e);
117try118 {
119 data.getOut().print("Error processing ecs screen '" + name + "'. See log for more information.");
120 }
121catch (java.io.IOException ioe)
122 {
123 }
124 }
125return SKIP_BODY;
126 }
127 }