1 5 package org.exoplatform.portlets.content.display.component; 6 7 import java.util.Enumeration; 8 import java.util.List; 9 import javax.faces.context.ExternalContext; 10 import javax.faces.context.FacesContext; 11 import javax.portlet.PortletPreferences; 12 import javax.portlet.PortletRequest; 13 import org.exoplatform.faces.core.component.UIPortlet; 14 import org.exoplatform.portlets.content.display.component.model.ContentConfig; 15 21 public class UIContentPortlet extends UIPortlet { 22 23 final static public String[] DEFAULT_VALUES = { "title=", "uri=", "encoding="}; 24 25 public UIContentPortlet() throws Exception { 26 setClazz("UIContentPortlet"); 27 setRendererType("PyramidTabBarRenderer") ; 28 ExternalContext eContext = FacesContext.getCurrentInstance().getExternalContext(); 29 PortletRequest request = (PortletRequest) eContext.getRequest(); 30 PortletPreferences prefs = request.getPreferences(); 31 Enumeration enum = prefs.getNames(); 32 List children = getChildren(); 33 boolean select = true; 34 while (enum.hasMoreElements()) { 35 String name = (String) enum.nextElement(); 36 String[] values = prefs.getValues(name, DEFAULT_VALUES); 37 ContentConfig contentConfig = new ContentConfig(name, values); 38 UIContentTab uiContentTab = createUIContentTab(contentConfig); 39 uiContentTab.setId("id" + Integer.toString(uiContentTab.hashCode())); 40 uiContentTab.setRendered(select); 41 children.add(uiContentTab); 42 select = false; 43 } 44 } 45 46 protected UIContentTab createUIContentTab(ContentConfig contentConfig) throws Exception{ 47 return new UIContentTab(contentConfig); 48 } 49 } | Popular Tags |