View Javadoc

1   package org.apache.turbine.modules.layouts;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "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      /***
45       * Build the layout.
46       *
47       * <p><em>NOTE: Unless otherwise specified, the page background
48       * defaults to 'white'</em></p>
49       *
50       * @param data Turbine information.
51       * @exception Exception a generic exception.
52       */
53      public void doBuild(RunData data) throws Exception
54      {
55          // Execute the Top Navigation portion for this Layout.
56          ConcreteElement topNav = NavigationLoader.getInstance()
57                  .eval(data, "DefaultTopNavigation");
58  
59          if (topNav != null)
60          {
61              data.getPage().getBody().addElement(topNav);
62          }
63  
64          // If an Action has defined a message, attempt to display it here.
65          if (data.getMessage() != null)
66          {
67              data.getPage().getBody().addElement(new P())
68                      .addElement(new Font().setColor(HtmlColor.red)
69                      .addElement(data.getMessageAsHTML()));
70          }
71  
72          // Now execute the Screen portion of the page.
73          ConcreteElement screen = ScreenLoader.getInstance()
74                  .eval(data, data.getScreen());
75  
76          if (screen != null)
77          {
78              data.getPage().getBody().addElement(screen);
79          }
80  
81          // The screen should have attempted to set a Title for itself,
82          // otherwise, a default title is set.
83          data.getPage().getTitle().addElement(data.getTitle());
84  
85          // The screen should have attempted to set a Body bgcolor for
86          // itself, otherwise, a default body bgcolor is set.
87          data.getPage().getBody().setBgColor(HtmlColor.white);
88  
89          // Execute the Bottom Navigation portion for this Layout.
90          ConcreteElement bottomNav = NavigationLoader.getInstance().eval(data,
91                  "DefaultBottomNavigation");
92  
93          if (bottomNav != null)
94          {
95              data.getPage().getBody().addElement(bottomNav);
96          }
97      }
98  }