1 5 package org.exoplatform.portlets.backup.renderer.html; 6 7 import java.io.IOException ; 8 import java.util.List ; 9 import java.util.ResourceBundle ; 10 import javax.faces.component.UIComponent; 11 import javax.faces.context.FacesContext; 12 import javax.faces.context.ResponseWriter; 13 import org.exoplatform.faces.core.component.model.Parameter; 14 import org.exoplatform.faces.core.renderer.html.HtmlBasicRenderer; 15 import org.exoplatform.portlets.backup.component.UIExportData; 16 import org.exoplatform.services.backup.ImporterExporter; 17 23 public class ExportDataRenderer extends HtmlBasicRenderer { 24 private static Parameter EXPORT_DATA = new Parameter(ACTION , "exportData") ; 25 private static Parameter[] exportAllParams = { new Parameter(ACTION , "exportAll") } ; 26 27 public void encodeChildren( FacesContext context, UIComponent component ) throws IOException { 28 UIExportData uiExportData = (UIExportData) component; 29 ResourceBundle res = getApplicationResourceBundle(context.getExternalContext()) ; 30 ResponseWriter w = context.getResponseWriter() ; 31 String exportDataButton = res.getString("UIExportData.button.export-data") ; 32 String exportAllButton = res.getString("UIExportData.button.export-all") ; 33 Parameter nameParam = new Parameter("name" , ""); 34 Parameter[] exportDataParams = { EXPORT_DATA , nameParam} ; 35 List importersExporters = uiExportData.getImportersExporters() ; 36 w.write("<table class='UIExportData'>") ; 37 w. write("<tr>") ; 38 w. write("<th>"); w.write(res.getString("UIExportData.header.importer-exporter-name")) ;w.write("</th>") ; 39 w. write("<th>"); w.write(res.getString("UIExportData.header.description")); w.write("</th>") ; 40 w. write("<th>"); w.write(res.getString("UIExportData.header.action")); w.write("</th>") ; 41 w. write("</tr>") ; 42 for (int i = 0; i < importersExporters.size(); i++) { 43 ImporterExporter ie = (ImporterExporter) importersExporters.get(i) ; 44 nameParam.setValue(ie.getName()) ; 45 String clazz = "odd"; 46 if (i % 2 == 0) 47 clazz = "even"; 48 w.write("<tr class='" + clazz + "'>") ; 49 w. write("<td>") ; w.write(ie.getName()); w.write("</td>") ; 50 w. write("<td>") ; w.write(ie.getDescription()); w.write("</td>") ; 51 w. write("<td>") ; 52 linkRenderer_.render(w,uiExportData, exportDataButton, exportDataParams) ; 53 w. write("</td>") ; 54 w.write("</tr>") ; 55 } 56 57 if(uiExportData.hasAdminRole()) { 58 w.write("<tr class='footer'>") ; 59 w. write("<td colspan='3' style='text-align: center;'>") ; 60 linkRenderer_.render(w,uiExportData, exportAllButton, exportAllParams) ; 61 w. write("</td>") ; 62 w.write("</tr>") ; 63 } 64 w.write("</table>") ; 65 } 66 } | Popular Tags |