KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portal > faces > component > UISinglePage


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.portal.faces.component;
6
7 import java.util.List JavaDoc;
8 import javax.faces.component.UIComponent;
9 import javax.faces.context.FacesContext;
10 import javax.servlet.http.HttpServletRequest JavaDoc;
11 import org.apache.commons.lang.StringUtils;
12 import org.exoplatform.services.portal.model.Component;
13 import org.exoplatform.services.portal.model.Container;
14 import org.exoplatform.services.portal.skin.SkinConfigService;
15 import org.exoplatform.services.portal.skin.model.Style;
16 /**
17  * Date: Aug 11, 2003
18  * @author: Tuan Nguyen
19  * @email: tuan08@users.sourceforge.net
20  * @version: $Id: UISinglePage.java,v 1.7 2004/10/22 23:49:42 tuan08 Exp $
21  */

22 public class UISinglePage extends UIBasicComponent {
23   
24   public static final String JavaDoc DEFAULT_RENDERER_TYPE = "SinglePageRenderer";
25
26   private String JavaDoc userCss_ ;
27
28   public UISinglePage() {
29     try {
30       FacesContext context = FacesContext.getCurrentInstance() ;
31       HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc) context.getExternalContext().getRequest();
32       String JavaDoc[] portletNames = request.getParameterValues("portletName") ;
33       String JavaDoc style = request.getParameter("style") ;
34       List JavaDoc children = getChildren() ;
35       if (portletNames != null) {
36         for (int i = 0; i < portletNames.length; i++) {
37           String JavaDoc[] keys = StringUtils.split(portletNames[i], "/") ;
38           String JavaDoc portletApp = keys[0] ;
39           String JavaDoc portletName = keys[1] ;
40           String JavaDoc id = "window-" + portletName ;
41           if (keys.length == 3) id = keys[2] ;
42           UIPortlet uiPortlet = new UIPortlet(portletApp, portletName, id) ;
43           if(style != null && style.length() > 0) {
44             uiPortlet.getPortletModel().setPortletStyle(style) ;
45           }
46           children.add(uiPortlet) ;
47         }
48       } else {
49         log_.warn("NO PORTLET NAME IS FOUND");
50       }
51       setRendererType(getRendererType());
52       setId("single-page");
53     } catch (Throwable JavaDoc t) {
54       t.printStackTrace() ;
55     }
56     
57     new ChangeLocaleVisitor().changeLocale(this, "en") ;
58     userCss_ = CssStyleBuilderVisitor.getCSS(this) ;
59   }
60   
61   public Component getComponentModel() { return null ;}
62   
63   protected Style getDecoratorStyle(SkinConfigService service, String JavaDoc renderer, String JavaDoc style) {
64     return null ;
65   }
66   protected String JavaDoc getComponentIdPrefix() { return "" ; }
67   public String JavaDoc getFamily() { return "org.exoplatform.portal.faces.component.UISinglePage" ; }
68   public String JavaDoc getIdPrefix() { return "sp" ; }
69   protected String JavaDoc getSkinName() { return "default" ; }
70   public String JavaDoc getUserCss() { return userCss_ ; }
71   protected String JavaDoc getDefaultRendererType() { return DEFAULT_RENDERER_TYPE ; }
72
73   public String JavaDoc getRendererType() {
74         /*
75          * TODO : Test of user-agent and MIME type or markup parameters found
76          * in ExoPortalInfo instance (no yet implemented) to choose correct
77          * renderer type
78          */

79         return DEFAULT_RENDERER_TYPE;
80   }
81
82   public void processDecodes(FacesContext context) {
83     List JavaDoc children = getChildren() ;
84     for (int i = 0; i < children.size() ; i++) {
85       UIComponent child = (UIComponent) children.get(i) ;
86       if (context.getRenderResponse()) return ;
87       child.processDecodes(context) ;
88     }
89   }
90
91   public boolean getRendersChildren(){
92     return true;
93   }
94   
95   public void buildTreeModel(Container parent) {
96     
97   }
98 }
Popular Tags