1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
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  }