1 5 package org.exoplatform.portlets.backup.renderer.html; 6 7 import java.io.IOException ; 8 import java.util.Enumeration ; 9 import java.util.ResourceBundle ; 10 import java.util.jar.JarEntry ; 11 import javax.faces.component.UIComponent; 12 import javax.faces.context.FacesContext; 13 import javax.faces.context.ResponseWriter; 14 import org.exoplatform.faces.core.component.model.Parameter; 15 import org.exoplatform.faces.core.renderer.html.HtmlBasicRenderer; 16 import org.exoplatform.portlets.backup.component.UIData; 17 import org.exoplatform.portlets.backup.component.model.ImportData; 18 19 26 27 public class DataRenderer extends HtmlBasicRenderer { 28 private static Parameter IMPORT_DATA = new Parameter(ACTION, "importData"); 29 private static Parameter[] cancelParams = {new Parameter(ACTION, "cancel")}; 30 31 public void encodeChildren(FacesContext context, UIComponent component) throws IOException { 32 UIData uiData = (UIData) component; 33 ResourceBundle res = getApplicationResourceBundle(context.getExternalContext()); 34 String cancelButton = res.getString("UIData.button.cancel"); 35 ResponseWriter w = context.getResponseWriter(); 36 ImportData data = uiData.getImportDataModel(); 37 w.write("<div class='UIData'>"); 40 w. write("<table class='meta-data'>"); 41 w. write("<tr>"); 42 w. write("<th>"); 43 w. write(res.getString("UIData.header.name")); 44 w. write("</th>"); 45 w. write("<td>"); 46 w. write(data.getName()); 47 w. write("</td>"); 48 w. write("</tr>"); 49 w. write("<tr>"); 50 w. write("<th>"); 51 w. write(res.getString("UIData.header.created-date")); 52 w. write("</th>"); 53 w. write("<td>"); 54 w. write(ft_.format(data.getCreatedDate())); 55 w. write("</td>"); 56 w. write("</tr>"); 57 w. write("<tr>"); 58 w. write("<th>"); 59 w. write(res.getString("UIData.header.modified-date")); 60 w. write("</th>"); 61 w. write("<td>"); 62 w. write(ft_.format(data.getModifiedDate())); 63 w. write("</td>"); 64 w. write("</tr>"); 65 w. write("</table>"); 66 w. write("<table class='data'>"); 67 w. write("<tr>"); 68 w. write("<th colspan='2'>"); 69 w. write(res.getString("UIData.header.entries")); 70 w. write("</th>"); 71 w. write("</tr>"); 72 Enumeration e = data.getEntries(); 73 int i = 0; 74 while (e.hasMoreElements()) { 75 JarEntry entry = (JarEntry ) e.nextElement(); 76 String clazz = "odd"; 77 if (i % 2 == 0) 78 clazz = "even"; 79 w. write("<tr class='" + clazz + "'>"); 80 w. write("<td colspan='2'>"); 81 w. write(entry.getName()); 82 w. write("</td>"); 83 w. write("</tr>"); 84 i++; 85 } 86 w. write("</tr>"); 87 w.write("</table>"); 88 w.write("<table class='footer'>"); 89 w. write("<tr>"); 90 w. write("<td colspan='2' style='text-align: center'>"); 91 linkRenderer_.render(w, uiData, cancelButton, cancelParams); 92 w. write("</td>"); 93 w. write("</tr>"); 94 w.write("</table>"); 95 w.write("</div>"); 96 } 97 } | Popular Tags |