1packageorg.apache.jetspeed.services.jsp.tags;
23/*4 * Copyright 2000-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 */1819import javax.servlet.jsp.JspException;
20import javax.servlet.jsp.PageContext;
21import javax.servlet.jsp.tagext.TagSupport;
2223// Turbine Classes 24import org.apache.turbine.modules.ScreenLoader;
25import org.apache.turbine.util.RunData;
26import org.apache.turbine.services.jsp.JspService;
27import org.apache.turbine.services.resources.TurbineResources;
28import org.apache.ecs.ConcreteElement;
2930// Jetspeed classes31import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
32import org.apache.jetspeed.services.logging.JetspeedLogger;
3334/***35 * Supporting class for the ecsscreen tag.36 * Sends the screens ecs element's content to the output stream. 37 * RunData's screen value is expected to be set!38 *39 * @author <a href="mailto:ingo@raleigh.ibm.com">Ingo Schuster</a>40 * @version $Id: EcsScreenTag.java,v 1.12 2004/02/23 03:59:40 jford Exp $41 */42publicclassEcsScreenTagextends TagSupport
43 {
44/***45 * Static initialization of the logger for this class46 */47privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(EcsScreenTag.class.getName());
4849/***50 * Method called when the tag is encountered to send attributes to the51 * output stream52 *53 * @return SKIP_BODY, as it is intended to be a single tag.54 */55publicint doStartTag() throws JspException
56 {
57 RunData data = (RunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
58 String screenName = data.getScreen();
5960// make sure that not the BaseJspScreen is called 61// as this would result in an endless loop...62if ( screenName.equals( "BaseJspScreen" ) )
63 {
64 screenName = TurbineResources.getString("screen.homepage");
65 }
6667try68 {
69 pageContext.getOut().flush();
7071 ConcreteElement screenElement = ScreenLoader.getInstance().eval( data, screenName );
7273// Check whether this is an "old" screen (that returns a ConcreteElement)74// or a "new" one that returns null.75if ( screenElement != null )
76 {
77//The ECS element must serialize in the character encoding78// of the response79 screenElement.setCodeSet( data.getResponse().getCharacterEncoding() );
8081 screenElement.output( data.getResponse().getWriter() );
82 }
8384 }
85catch (Exception e)
86 {
87 String message = "Error processing ecs screen '" + screenName + "'.";
88 logger.error(message, e);
89try90 {
91 data.getOut().print("Error processing ecs screen '" + screenName + "'. See log for more information.");
92 }
93catch(java.io.IOException ioe) {}
94 }
95return SKIP_BODY;
96 }
97 }