1/*2 * Copyright 2000-2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.modules.layouts;
1819//jetspeed stuff20import org.apache.jetspeed.capability.CapabilityMap;
21import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
22import org.apache.jetspeed.services.logging.JetspeedLogger;
23import org.apache.jetspeed.services.rundata.JetspeedRunData;
24import org.apache.jetspeed.services.resources.JetspeedResources;
25import org.apache.jetspeed.util.MimeType;
2627// Turbine28import org.apache.turbine.modules.Layout;
29import org.apache.turbine.modules.NavigationLoader;
30import org.apache.turbine.modules.ScreenLoader;
31import org.apache.turbine.util.RunData;
3233// ECS Classes34import org.apache.ecs.*;
35import org.apache.ecs.wml.*;
36import org.apache.ecs.xml.*;
3738/***39 * Legacy jetspeed Layout used when handling ECS-only content.40 * You should not use it if you want to use Velocity or JSPs.41 *42 * @deprecated This layout is not used anymore in Jetspeed43 * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>44 * @author <a href="mailto:raphael@apache.org">Raphaël Lute</a>45 * @version $Id: JetspeedLayout.java,v 1.13 2004/02/23 02:59:30 jford Exp $46 */47publicclassJetspeedLayoutextends Layout
48 {
4950publicstaticfinal String TOP =
51 JetspeedResources.getString( JetspeedResources.NAVIGATIONS_TOP_KEY );
5253publicstaticfinal String BOTTOM =
54 JetspeedResources.getString( JetspeedResources.NAVIGATIONS_BOTTOM_KEY );
5556/***57 The Doctype of WML58 */59publicstaticfinal Doctype WML_DOCTYPE =
60new Doctype( "wml",
61"PUBLIC",
62"\"-//WAPFORUM//DTD WML 1.1//EN\"",
63"\"http://www.wapforum.org/DTD/wml_1.1.xml\"" );
646566/***67 * Static initialization of the logger for this class68 */69privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(JetspeedLayout.class.getName());
7071/***72 * 73 */74publicvoid doBuild( RunData data ) throws Exception
75 {
7677CapabilityMap cm = ((JetspeedRunData)data).getCapability();
7879MimeType mt = cm.getPreferredType();
80 data.setContentType( mt.getContentType() );
81 data.setCharSet( mt.getCharSet() );
8283if ( logger.isDebugEnabled() )
84 {
85 logger.debug( "Layout: Setting type to: " + mt );
86 }
8788if ( mt.equals( MimeType.WML ) ) {
89// we should output WML code, use raw output90// don"t use navigations for WML9192 ElementContainer ec = new ElementContainer();
93 WML wml = new WML();
94 ec.addElement( new PI().setVersion( 1.0 ) );
95 ec.addElement( WML_DOCTYPE );
96 ec.addElement( wml );
97 wml.addElement( new Template().addElement( new Do( DoType.ACCEPT, "Back" ).addElement( new Prev() ) ) );
9899// Now execute the Screen portion of the page100 ConcreteElement screen = ScreenLoader.getInstance().eval ( data, data.getScreen() );
101if (screen != null)
102 wml.addElement( screen );
103104// output everything on stdout105try {
106 ec.output( data.getOut() );
107 } catch ( java.io.IOException e ) {
108 logger.error("Exception", e);
109 } finally {
110 ec = null;
111 }
112113 } else {
114115// Execute the Top Navigation portion for this Layout116 ConcreteElement topNav =
117 NavigationLoader.getInstance().eval ( data, TOP );
118if ( topNav != null)
119 data.getPage().getBody().addElement( topNav );
120121// Now execute the Screen portion of the page122 ConcreteElement screen = ScreenLoader.getInstance().eval ( data, data.getScreen() );
123if (screen != null)
124 data.getPage().getBody().addElement( screen );
125126// The screen should have attempted to set a Title127// for itself, otherwise, a default title is set128 data.getPage().getTitle()
129 .addElement( data.getTitle() );
130131// The screen should have attempted to set a Body bgcolor132// for itself, otherwise, a default body bgcolor is set133 data.getPage().getBody()
134 .setBgColor(HtmlColor.white);
135136// Execute the Bottom Navigation portion for this Layout137 ConcreteElement bottomNav =
138 NavigationLoader.getInstance().eval ( data, BOTTOM );
139if ( bottomNav != null)
140 data.getPage().getBody().addElement( bottomNav );
141 }
142 }
143144 }