01: package org.apache.turbine.modules.layouts;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import org.apache.ecs.ConcreteElement;
23: import org.apache.ecs.HtmlColor;
24:
25: import org.apache.ecs.html.Font;
26: import org.apache.ecs.html.P;
27:
28: import org.apache.turbine.modules.Layout;
29: import org.apache.turbine.modules.NavigationLoader;
30: import org.apache.turbine.modules.ScreenLoader;
31:
32: import org.apache.turbine.util.RunData;
33:
34: /**
35: * This is an example Layout module that is executed by default.
36: *
37: * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
38: * @version $Id: DefaultLayout.java 534527 2007-05-02 16:10:59Z tv $
39: * @deprecated The use of ECS for the view is deprecated.
40: * Use a templating solution.
41: */
42: public class DefaultLayout extends Layout {
43: /**
44: * Build the layout.
45: *
46: * <p><em>NOTE: Unless otherwise specified, the page background
47: * defaults to 'white'</em></p>
48: *
49: * @param data Turbine information.
50: * @exception Exception a generic exception.
51: */
52: public void doBuild(RunData data) throws Exception {
53: // Execute the Top Navigation portion for this Layout.
54: ConcreteElement topNav = NavigationLoader.getInstance().eval(
55: data, "DefaultTopNavigation");
56:
57: if (topNav != null) {
58: data.getPage().getBody().addElement(topNav);
59: }
60:
61: // If an Action has defined a message, attempt to display it here.
62: if (data.getMessage() != null) {
63: data.getPage().getBody().addElement(new P()).addElement(
64: new Font().setColor(HtmlColor.red).addElement(
65: data.getMessageAsHTML()));
66: }
67:
68: // Now execute the Screen portion of the page.
69: ConcreteElement screen = ScreenLoader.getInstance().eval(data,
70: data.getScreen());
71:
72: if (screen != null) {
73: data.getPage().getBody().addElement(screen);
74: }
75:
76: // The screen should have attempted to set a Title for itself,
77: // otherwise, a default title is set.
78: data.getPage().getTitle().addElement(data.getTitle());
79:
80: // The screen should have attempted to set a Body bgcolor for
81: // itself, otherwise, a default body bgcolor is set.
82: data.getPage().getBody().setBgColor(HtmlColor.white);
83:
84: // Execute the Bottom Navigation portion for this Layout.
85: ConcreteElement bottomNav = NavigationLoader.getInstance()
86: .eval(data, "DefaultBottomNavigation");
87:
88: if (bottomNav != null) {
89: data.getPage().getBody().addElement(bottomNav);
90: }
91: }
92: }
|