KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > backup > renderer > html > ExportDataRenderer


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.backup.renderer.html;
6
7 import java.io.IOException JavaDoc;
8 import java.util.List JavaDoc;
9 import java.util.ResourceBundle JavaDoc;
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 /**
18  * May 31, 2004
19  * @author: Tuan Nguyen
20  * @email: tuan08@users.sourceforge.net
21  * @version: $ID$
22  **/

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 JavaDoc {
28     UIExportData uiExportData = (UIExportData) component;
29     ResourceBundle JavaDoc res = getApplicationResourceBundle(context.getExternalContext()) ;
30     ResponseWriter w = context.getResponseWriter() ;
31     String JavaDoc exportDataButton = res.getString("UIExportData.button.export-data") ;
32     String JavaDoc exportAllButton = res.getString("UIExportData.button.export-all") ;
33     Parameter nameParam = new Parameter("name" , "");
34     Parameter[] exportDataParams = { EXPORT_DATA , nameParam} ;
35     List JavaDoc 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 JavaDoc 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