1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.modules.layouts;
18
19
20 import org.apache.jetspeed.capability.CapabilityMap;
21 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
22 import org.apache.jetspeed.services.logging.JetspeedLogger;
23 import org.apache.jetspeed.services.rundata.JetspeedRunData;
24 import org.apache.jetspeed.services.resources.JetspeedResources;
25 import org.apache.jetspeed.util.MimeType;
26
27
28 import org.apache.turbine.modules.Layout;
29 import org.apache.turbine.modules.NavigationLoader;
30 import org.apache.turbine.modules.ScreenLoader;
31 import org.apache.turbine.util.RunData;
32
33
34 import org.apache.ecs.*;
35 import org.apache.ecs.wml.*;
36 import org.apache.ecs.xml.*;
37
38 /***
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 Jetspeed
43 * @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 */
47 public class JetspeedLayout extends Layout
48 {
49
50 public static final String TOP =
51 JetspeedResources.getString( JetspeedResources.NAVIGATIONS_TOP_KEY );
52
53 public static final String BOTTOM =
54 JetspeedResources.getString( JetspeedResources.NAVIGATIONS_BOTTOM_KEY );
55
56 /***
57 The Doctype of WML
58 */
59 public static final Doctype WML_DOCTYPE =
60 new Doctype( "wml",
61 "PUBLIC",
62 "\"-//WAPFORUM//DTD WML 1.1//EN\"",
63 "\"http://www.wapforum.org/DTD/wml_1.1.xml\"" );
64
65
66 /***
67 * Static initialization of the logger for this class
68 */
69 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(JetspeedLayout.class.getName());
70
71 /***
72 *
73 */
74 public void doBuild( RunData data ) throws Exception
75 {
76
77 CapabilityMap cm = ((JetspeedRunData)data).getCapability();
78
79 MimeType mt = cm.getPreferredType();
80 data.setContentType( mt.getContentType() );
81 data.setCharSet( mt.getCharSet() );
82
83 if ( logger.isDebugEnabled() )
84 {
85 logger.debug( "Layout: Setting type to: " + mt );
86 }
87
88 if ( mt.equals( MimeType.WML ) ) {
89
90
91
92 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() ) ) );
98
99
100 ConcreteElement screen = ScreenLoader.getInstance().eval ( data, data.getScreen() );
101 if (screen != null)
102 wml.addElement( screen );
103
104
105 try {
106 ec.output( data.getOut() );
107 } catch ( java.io.IOException e ) {
108 logger.error("Exception", e);
109 } finally {
110 ec = null;
111 }
112
113 } else {
114
115
116 ConcreteElement topNav =
117 NavigationLoader.getInstance().eval ( data, TOP );
118 if ( topNav != null)
119 data.getPage().getBody().addElement( topNav );
120
121
122 ConcreteElement screen = ScreenLoader.getInstance().eval ( data, data.getScreen() );
123 if (screen != null)
124 data.getPage().getBody().addElement( screen );
125
126
127
128 data.getPage().getTitle()
129 .addElement( data.getTitle() );
130
131
132
133 data.getPage().getBody()
134 .setBgColor(HtmlColor.white);
135
136
137 ConcreteElement bottomNav =
138 NavigationLoader.getInstance().eval ( data, BOTTOM );
139 if ( bottomNav != null)
140 data.getPage().getBody().addElement( bottomNav );
141 }
142 }
143
144 }