KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.IOException JavaDoc;
7 import javax.portlet.*;
8 import org.exoplatform.commons.utils.ExceptionUtil;
9 import org.exoplatform.portlet.exomvc.config.Configuration;
10 import org.exoplatform.portlet.exomvc.config.PageConfig ;
11 /**
12  * Created by The eXo Platform SARL .
13  * Author : Tuan Nguyen
14  * tuan08@users.sourceforge.net
15  * Tue, Jun 03, 2003 @
16  * Time: 11:26:44 PM
17  */

18
19 public class MVCPortletFramework extends GenericPortlet {
20   final public static PortletMode CONFIG_MODE = new PortletMode("config") ;
21
22   private Configuration configuration_ ;
23   
24   public void init(PortletConfig config) throws PortletException {
25     super.init(config);
26     try {
27       configuration_ = new Configuration(config) ;
28     } catch (Exception JavaDoc ex) {
29       ex.printStackTrace() ;
30     }
31   }
32   
33   public void render (RenderRequest req, RenderResponse res) throws PortletException, java.io.IOException JavaDoc {
34     res.setTitle(getTitle(req));
35     WindowState state = req.getWindowState();
36     if (!state.equals(WindowState.MINIMIZED)) {
37       try {
38         res.setContentType("text/html") ;
39         PortletMode mode = req.getPortletMode();
40         String JavaDoc pageName = req.getParameter(Page.FORWARD_PAGE) ;
41         PageConfig pconfig = configuration_.getPageConfig(mode, pageName) ;
42         Page page = pconfig.getPageObject(configuration_) ;
43         PageDecorator decorator = pconfig.getPageDecorator() ;
44         if(decorator != null) {
45           decorator.decorate(page, req, res) ;
46         } else {
47           page.render(req, res) ;
48         }
49       } catch (Throwable JavaDoc t) {
50         String JavaDoc trace = ExceptionUtil.getExoStackTrace(t) ;
51         res.getWriter().write(trace) ;
52       }
53     }
54   }
55
56   public void processAction(ActionRequest req, ActionResponse res)
57   throws PortletException, IOException JavaDoc {
58     try {
59       PortletMode mode = req.getPortletMode();
60       String JavaDoc pageName = req.getParameter(Page.PAGE_NAME) ;
61       PageConfig pconfig = configuration_.getPageConfig(mode, pageName) ;
62       Page page = pconfig.getPageObject(configuration_) ;
63       page.processAction(req, res) ;
64     } catch (Throwable JavaDoc t) {
65       String JavaDoc trace = ExceptionUtil.getExoStackTrace(t) ;
66       //System.out.println(trace) ;
67
}
68   }
69   
70   public void destroy() {
71     configuration_.destroy() ;
72     super.destroy() ;
73   }
74 }
Popular Tags