1 5 package org.exoplatform.portlets.content.display.component; 6 7 import java.io.IOException ; 8 import java.util.ResourceBundle ; 9 import javax.faces.context.FacesContext; 10 import javax.faces.context.ResponseWriter; 11 import org.exoplatform.container.SessionContainer; 12 import org.exoplatform.faces.core.component.UINode; 13 import org.exoplatform.portal.session.ExoPortal; 14 import org.exoplatform.portal.session.PortalResources; 15 import org.exoplatform.portlets.content.ContentUtil; 16 import org.exoplatform.portlets.content.display.component.model.ContentConfig; 17 import org.exoplatform.services.portal.model.Node; 18 24 public class UIContentTab extends UINode { 25 protected ContentConfig config_; 26 27 public UIContentTab(ContentConfig config) throws Exception { 28 config_ = config; 29 } 30 31 public String getName() { 32 PortalResources appres = 33 (PortalResources)SessionContainer.getComponent(PortalResources.class); 34 ResourceBundle res = appres.getApplicationOwnerResource() ; 35 String text2return = null; 36 try { 37 text2return = res.getString(config_.getTitle()); 38 } catch(Exception ex){ 39 text2return = config_.getTitle(); 40 } 41 return text2return; 42 } 43 44 public void encodeBegin(FacesContext context) throws IOException { 45 } 46 47 public void encodeChildren(FacesContext context) throws IOException { 48 ResponseWriter w = context.getResponseWriter() ; 49 w.write("<div class='UIContentTab'>") ; 50 ExoPortal portal = (ExoPortal)SessionContainer.getComponent(ExoPortal.class) ; 51 Node selectedNode = portal.getSelectedNode(); 52 String content = ContentUtil.resolveContent(config_, selectedNode); 53 if(content == null){ 54 w. write("No configuration for the content") ; 55 } else { 56 w. write(content) ; 57 } 58 w.write("</div>") ; 59 } 60 61 public void encodeEnd(FacesContext context) throws IOException { 62 } 63 } | Popular Tags |