1 package org.apache.jetspeed.services.jsp.tags;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import javax.servlet.jsp.JspException;
21 import javax.servlet.jsp.PageContext;
22 import javax.servlet.jsp.tagext.TagSupport;
23
24
25 import org.apache.turbine.services.jsp.JspService;
26
27 import org.apache.ecs.ConcreteElement;
28
29
30 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
31 import org.apache.jetspeed.services.logging.JetspeedLogger;
32 import org.apache.jetspeed.services.resources.JetspeedResources;
33 import org.apache.jetspeed.services.rundata.JetspeedRunData;
34 import org.apache.jetspeed.util.template.JetspeedTool;
35
36 /***
37 * Supporting class for the pane tag.
38 * Builds the output of a PSML config file and insert it within the
39 * current JSP page
40 *
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 */
45 public class JetspeedPaneTag extends TagSupport
46 {
47 /***
48 * Static initialization of the logger for this class
49 */
50 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(JetspeedPaneTag.class.getName());
51
52 private String name = null;
53
54 public void setName(String name)
55 {
56 this.name = name;
57 }
58
59 public String getName()
60 {
61 return this.name;
62 }
63
64 /***
65 * Method called when the tag is encountered to send attributes to the
66 * output stream
67 *
68 * @return SKIP_BODY, as it is intended to be a single tag.
69 */
70 public int doStartTag() throws JspException
71 {
72 JetspeedRunData data = (JetspeedRunData) pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
73
74
75 if (this.name == null)
76 {
77 this.name = JetspeedResources.getString("screen.homepage");
78 }
79
80 try
81 {
82 pageContext.getOut().flush();
83
84 ConcreteElement result = new ConcreteElement();
85
86 if (data != null && data.getUser() != null)
87 {
88 JetspeedTool jt = new JetspeedTool(data);
89 String jspeid = (String) data.getUser().getTemp("js_peid");
90 if (jspeid != null)
91 {
92 data.setMode(JetspeedRunData.MAXIMIZE);
93 result = jt.getPortletById(jspeid);
94 }
95 else
96 {
97 result = jt.getPane(this.name);
98 }
99 }
100
101
102
103 if (result != null)
104 {
105
106
107 result.setCodeSet(data.getResponse().getCharacterEncoding());
108
109 result.output(data.getResponse().getWriter());
110 }
111
112 }
113 catch (Exception e)
114 {
115 String message = "Error processing name '" + name + "'.";
116 logger.error(message, e);
117 try
118 {
119 data.getOut().print("Error processing ecs screen '" + name + "'. See log for more information.");
120 }
121 catch (java.io.IOException ioe)
122 {
123 }
124 }
125 return SKIP_BODY;
126 }
127 }