KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlet > exomvc > PageDecorator


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlet.exomvc;
6
7 import javax.portlet.RenderRequest;
8 import javax.portlet.RenderResponse ;
9 /**
10  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
11  * @since Nov 12, 2004
12  * @version $Id$
13  */

14 public class PageDecorator {
15   PageDecorator nextDecorator_ ;
16   
17   public void decorate(Page page, RenderRequest req, RenderResponse res) throws Exception JavaDoc {
18     render(page, req, res) ;
19   }
20   
21   protected void render(Page page, RenderRequest req, RenderResponse res) throws Exception JavaDoc {
22     if(nextDecorator_ != null) {
23       nextDecorator_.decorate(page, req, res) ;
24     } else {
25       page.render(req, res) ;
26     }
27   }
28   
29   final public PageDecorator addPageDecorator(PageDecorator decorator) {
30     if(decorator.nextDecorator_ != null) {
31       throw new RuntimeException JavaDoc("Expect a new page decorator instance, not a chain of decorator");
32     }
33     if(nextDecorator_ == null) {
34       nextDecorator_ = decorator ;
35     } else {
36       nextDecorator_.addPageDecorator(decorator) ;
37     }
38     return this ;
39   }
40 }
41
Popular Tags