KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > modules > layouts > DefaultLayout


1 package org.apache.turbine.modules.layouts;
2
3 /*
4  * Copyright 2001-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 at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * 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 and
16  * limitations under the License.
17  */

18
19 import org.apache.ecs.ConcreteElement;
20 import org.apache.ecs.HtmlColor;
21
22 import org.apache.ecs.html.Font;
23 import org.apache.ecs.html.P;
24
25 import org.apache.turbine.modules.Layout;
26 import org.apache.turbine.modules.NavigationLoader;
27 import org.apache.turbine.modules.ScreenLoader;
28
29 import org.apache.turbine.util.RunData;
30
31 /**
32  * This is an example Layout module that is executed by default.
33  *
34  * @author <a HREF="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
35  * @version $Id: DefaultLayout.java,v 1.6.2.2 2004/05/20 03:03:54 seade Exp $
36  * @deprecated The use of ECS for the view is deprecated.
37  * Use a templating solution.
38  */

39 public class DefaultLayout extends Layout
40 {
41     /**
42      * Build the layout.
43      *
44      * <p><em>NOTE: Unless otherwise specified, the page background
45      * defaults to 'white'</em></p>
46      *
47      * @param data Turbine information.
48      * @exception Exception a generic exception.
49      */

50     public void doBuild(RunData data) throws Exception JavaDoc
51     {
52         // Execute the Top Navigation portion for this Layout.
53
ConcreteElement topNav = NavigationLoader.getInstance()
54                 .eval(data, "DefaultTopNavigation");
55
56         if (topNav != null)
57         {
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         {
64             data.getPage().getBody().addElement(new P())
65                     .addElement(new Font().setColor(HtmlColor.red)
66                     .addElement(data.getMessageAsHTML()));
67         }
68
69         // Now execute the Screen portion of the page.
70
ConcreteElement screen = ScreenLoader.getInstance()
71                 .eval(data, data.getScreen());
72
73         if (screen != null)
74         {
75             data.getPage().getBody().addElement(screen);
76         }
77
78         // The screen should have attempted to set a Title for itself,
79
// otherwise, a default title is set.
80
data.getPage().getTitle().addElement(data.getTitle());
81
82         // The screen should have attempted to set a Body bgcolor for
83
// itself, otherwise, a default body bgcolor is set.
84
data.getPage().getBody().setBgColor(HtmlColor.white);
85
86         // Execute the Bottom Navigation portion for this Layout.
87
ConcreteElement bottomNav = NavigationLoader.getInstance().eval(data,
88                 "DefaultBottomNavigation");
89
90         if (bottomNav != null)
91         {
92             data.getPage().getBody().addElement(bottomNav);
93         }
94     }
95 }
96
Popular Tags