KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portal > faces > renderer > html > container > ContainerRenderer


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.renderer.html.container;
6
7 import java.io.IOException JavaDoc;
8 import java.util.ResourceBundle JavaDoc;
9 import javax.faces.component.UIComponent;
10 import javax.faces.context.FacesContext;
11 import javax.faces.context.ResponseWriter;
12 import org.exoplatform.container.SessionContainer;
13 import org.exoplatform.portal.PortalConstants;
14 import org.exoplatform.portal.faces.component.UIBasicComponent;
15 import org.exoplatform.portal.faces.component.UIContainer;
16 import org.exoplatform.portal.faces.renderer.BaseRenderer;
17 import org.exoplatform.portal.session.ExoPortal;
18 import org.exoplatform.portal.session.PortalResources;
19 /**
20  * Date: Aug 11, 2003
21  * @author : Mestrallet Benjamin
22  * @email: benjmestrallet@users.sourceforge.net
23  * @author: Tuan Nguyen
24  * @email: tuan08@users.sourceforge.net
25  * @version: $Id: ContainerRenderer.java,v 1.7 2004/09/21 03:41:34 tuan08 Exp $
26  */

27 abstract public class ContainerRenderer extends BaseRenderer {
28   
29   public void encodeChildren(FacesContext context, UIComponent uiComponent) throws IOException JavaDoc {
30     UIContainer uiContainer = (UIContainer) uiComponent ;
31     if(uiContainer.getComponentMode() == UIBasicComponent.COMPONENT_EDIT_MODE) {
32         renderEditMode(context, uiContainer);
33     } else {
34         renderViewMode(context, uiContainer);
35     }
36   }
37
38   private void renderEditMode(FacesContext context, UIContainer uiContainer) throws IOException JavaDoc {
39     PortalResources appres =
40       (PortalResources)SessionContainer.getComponent(PortalResources.class);
41     ResourceBundle JavaDoc res = appres.getApplicationResource();
42     ResponseWriter w = context.getResponseWriter();
43     w.write("<table class='customizer'");
44     w.write(" id='") ; w.write(uiContainer.getId());w.write("-customizer'>") ;
45     w. write("<tr>") ;
46     w. write("<th align='left'>");
47     w. write("Container " );
48     w. write("</th>");
49     w. write("<th align='right'>");
50     linkRenderer_.render(w, uiContainer, res.getString("UIContainer.button.add-portlet"), PortalConstants.addPortletParams);
51     linkRenderer_.render(w, uiContainer, res.getString("UIContainer.button.add-container"), PortalConstants.addContainerParams);
52     linkRenderer_.render(w, uiContainer, res.getString("UIContainer.button.edit-container"), PortalConstants.editParams);
53     linkRenderer_.render(w, uiContainer, res.getString("UIContainer.button.remove-container"),PortalConstants.deleteParams);
54     if(uiContainer.getFloat() == UIBasicComponent.FLOAT_BOTTOM) {
55       linkRenderer_.render(w, uiContainer, res.getString("UIContainer.button.move-up"), PortalConstants.moveUpParams);
56       linkRenderer_.render(w, uiContainer, res.getString("UIContainer.button.move-down"), PortalConstants.moveDownParams);
57     } else {
58       linkRenderer_.render(w, uiContainer, res.getString("UIContainer.button.move-left"), PortalConstants.moveUpParams);
59       linkRenderer_.render(w, uiContainer, res.getString("UIContainer.button.move-right"), PortalConstants.moveDownParams);
60     }
61     ExoPortal portal = (ExoPortal)SessionContainer.getComponent(ExoPortal.class) ;
62     if(portal.getPortalMode() != ExoPortal.PORTAL_EDIT_PAGE_MODE) {
63       linkRenderer_.render(w, uiContainer, res.getString("UIContainer.button.place-body"), PortalConstants.placeBodyParams);
64     }
65     w. write("</th>");
66     w. write("</tr>") ;
67     w. write("<tr>") ;
68     w. write("<td colspan='2' style='height: 100%'>");
69     renderViewMode(context, uiContainer) ;
70     w. write("</td>");
71     w. write("</tr>") ;
72     w.write("</table>") ;
73   }
74   
75   abstract protected void renderViewMode(FacesContext context, UIContainer uiContainer) throws IOException JavaDoc ;
76 }
Popular Tags