KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > content > display > component > UIContentTab


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.portlets.content.display.component;
6
7 import java.io.IOException JavaDoc;
8 import java.util.ResourceBundle JavaDoc;
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 /**
19  * Apr 26, 2004
20  * @author: Tuan Nguyen
21  * @email: tuan08@users.sourceforge.net
22  * @version: $Id: UIContentTab.java,v 1.2 2004/07/26 02:27:18 tuan08 Exp $
23  **/

24 public class UIContentTab extends UINode {
25   protected ContentConfig config_;
26     
27   public UIContentTab(ContentConfig config) throws Exception JavaDoc {
28     config_ = config;
29   }
30   
31   public String JavaDoc getName() {
32     PortalResources appres =
33       (PortalResources)SessionContainer.getComponent(PortalResources.class);
34     ResourceBundle JavaDoc res = appres.getApplicationOwnerResource() ;
35     String JavaDoc text2return = null;
36     try {
37       text2return = res.getString(config_.getTitle());
38     } catch(Exception JavaDoc ex){
39       text2return = config_.getTitle();
40     }
41     return text2return;
42   }
43   
44   public void encodeBegin(FacesContext context) throws IOException JavaDoc {
45   }
46   
47   public void encodeChildren(FacesContext context) throws IOException JavaDoc {
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 JavaDoc 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 JavaDoc {
62   }
63 }
Popular Tags