1 5 package org.exoplatform.portal.faces.renderer.html.container; 6 7 import java.io.IOException ; 8 import java.util.ResourceBundle ; 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 27 abstract public class ContainerRenderer extends BaseRenderer { 28 29 public void encodeChildren(FacesContext context, UIComponent uiComponent) throws IOException { 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 { 39 PortalResources appres = 40 (PortalResources)SessionContainer.getComponent(PortalResources.class); 41 ResourceBundle 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 ; 76 } | Popular Tags |