1 5 package org.exoplatform.portal.faces.component; 6 7 import java.util.List ; 8 import javax.faces.component.UIComponent; 9 import javax.faces.context.FacesContext; 10 import javax.servlet.http.HttpServletRequest ; 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 22 public class UISinglePage extends UIBasicComponent { 23 24 public static final String DEFAULT_RENDERER_TYPE = "SinglePageRenderer"; 25 26 private String userCss_ ; 27 28 public UISinglePage() { 29 try { 30 FacesContext context = FacesContext.getCurrentInstance() ; 31 HttpServletRequest request = (HttpServletRequest ) context.getExternalContext().getRequest(); 32 String [] portletNames = request.getParameterValues("portletName") ; 33 String style = request.getParameter("style") ; 34 List children = getChildren() ; 35 if (portletNames != null) { 36 for (int i = 0; i < portletNames.length; i++) { 37 String [] keys = StringUtils.split(portletNames[i], "/") ; 38 String portletApp = keys[0] ; 39 String portletName = keys[1] ; 40 String 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 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 renderer, String style) { 64 return null ; 65 } 66 protected String getComponentIdPrefix() { return "" ; } 67 public String getFamily() { return "org.exoplatform.portal.faces.component.UISinglePage" ; } 68 public String getIdPrefix() { return "sp" ; } 69 protected String getSkinName() { return "default" ; } 70 public String getUserCss() { return userCss_ ; } 71 protected String getDefaultRendererType() { return DEFAULT_RENDERER_TYPE ; } 72 73 public String getRendererType() { 74 79 return DEFAULT_RENDERER_TYPE; 80 } 81 82 public void processDecodes(FacesContext context) { 83 List 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 |