View Javadoc

1   /* ==========================================================================
2    * Copyright 2002-2005 Cyclops Group Community
3    * 
4    * Licensed under the Open Software License, Version 2.1 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://opensource.org/licenses/osl-2.1.php
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  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 and
14   *  limitations under the License.
15   * =========================================================================
16   */
17  package com.cyclopsgroup.waterview.core.taglib;
18  
19  import org.apache.commons.jelly.JellyTagException;
20  import org.apache.commons.jelly.XMLOutput;
21  
22  import com.cyclopsgroup.waterview.spi.LookAndFeelService;
23  import com.cyclopsgroup.waterview.spi.Page;
24  import com.cyclopsgroup.waterview.spi.Theme;
25  import com.cyclopsgroup.waterview.spi.taglib.TagSupport;
26  
27  /***
28   * Default layout definition tag
29   * 
30   * @author <a href="mailto:jiaqi.guo@gmail.com">Jiaqi Guo </a>
31   */
32  public class DefaultLayoutTag extends TagSupport
33  {
34      /***
35       * Overwrite or implement method processTag()
36       *
37       * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
38       */
39      public void processTag(XMLOutput output) throws Exception
40      {
41          Page page = (Page) context.getVariable(Page.NAME);
42          if (page == null)
43          {
44              throw new JellyTagException("JellyLayout must be in a page");
45          }
46          LookAndFeelService tm = (LookAndFeelService) getServiceManager()
47                  .lookup(LookAndFeelService.ROLE);
48          Theme theme = tm.getRuntimeTheme(getRuntimeData());
49          page.setLayout(theme.getLayout(Theme.LAYOUT_FOR_DEFAULT));
50      }
51  }