1 5 package org.exoplatform.portlet.exomvc; 6 7 import javax.portlet.RenderRequest; 8 import javax.portlet.RenderResponse ; 9 14 public class PageDecorator { 15 PageDecorator nextDecorator_ ; 16 17 public void decorate(Page page, RenderRequest req, RenderResponse res) throws Exception { 18 render(page, req, res) ; 19 } 20 21 protected void render(Page page, RenderRequest req, RenderResponse res) throws Exception { 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 ("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 |