KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > content > display > renderer > html > ContentConfigRenderer


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.content.display.renderer.html;
6
7 import java.util.* ;
8 import java.io.IOException JavaDoc;
9 import javax.faces.component.UIComponent;
10 import javax.faces.context.FacesContext;
11 import javax.faces.context.ResponseWriter;
12 import org.exoplatform.faces.core.component.model.Parameter;
13 import org.exoplatform.faces.core.renderer.html.HtmlBasicRenderer;
14 import org.exoplatform.portlets.content.display.component.UIContentConfig;
15 import org.exoplatform.portlets.content.display.component.model.ContentConfig;
16
17 /**
18  * @email: tuan08@users.sourceforge.net
19  * @version: $Id: ContentConfigRenderer.java,v 1.3 2004/07/26 02:27:19 tuan08 Exp $
20  */

21 public class ContentConfigRenderer extends HtmlBasicRenderer {
22
23   final public static String JavaDoc ADD_ICON = "<img class='add-icon' SRC='/skin/blank.gif'/>";
24
25     private static Parameter[] NEW = { new Parameter(ACTION , "new") };
26     private static Parameter EDIT = new Parameter(ACTION , "edit") ;
27     private static Parameter DELETE = new Parameter(ACTION , "delete") ;
28     private static Parameter MODIFY = new Parameter(ACTION , "modify") ;
29     
30   final public void encodeChildren(FacesContext context, UIComponent component ) throws IOException JavaDoc {
31     ResponseWriter w = context.getResponseWriter() ;
32     UIContentConfig uiContentConfig = (UIContentConfig) component ;
33     ResourceBundle res = getApplicationResourceBundle(context.getExternalContext()) ;
34     Parameter configName = new Parameter("name", "") ;
35     Parameter[] editParams = {EDIT , configName } ;
36     Parameter[] modifyParams = {MODIFY , configName } ;
37     Parameter[] deleteParams = { DELETE , configName } ;
38     String JavaDoc deleteButton = res.getString("UIContentConfig.button.delete") ;
39     String JavaDoc editButton = res.getString("UIContentConfig.button.edit") ;
40     String JavaDoc modifyButton = res.getString("UIContentConfig.button.modify") ;
41     String JavaDoc titleLabel = res.getString("UIContentConfig.label.title") ;
42     String JavaDoc uriLabel = res.getString("UIContentConfig.label.uri") ;
43     String JavaDoc encodingLabel = res.getString("UIContentConfig.label.encoding") ;
44     Map map = uiContentConfig.getAllConfigs() ;
45     String JavaDoc baseURL = uiContentConfig.getBaseURL(context) ;
46     Iterator i = map.values().iterator() ;
47     w.write("<div class='UIContentConfig'>") ;
48     while(i.hasNext()) {
49       ContentConfig config = (ContentConfig) i.next();
50       configName.setValue(config.getName()) ;
51       w.write("<table>") ;
52       w.write("<tr>") ;
53       w. write("<th align='left'>") ; w.write(config.getName()) ; w.write("</th>") ;
54       w.write("<th align='right'>");
55       appendLink(w, editButton, baseURL, editParams, "") ;
56       w. write("-");
57       if(uiContentConfig.isModificationAllowed()){
58         appendLink(w, modifyButton, baseURL, modifyParams, "") ;
59         w. write("-");
60       }
61       appendLink(w, deleteButton, baseURL, deleteParams, "") ;
62       w. write("</th>") ;
63       w.write("</tr>") ;
64       w.write("<tr>") ;
65       w. write("<td><label>") ; w.write(titleLabel) ; w.write("</label></td>") ;
66       w. write("<td>") ; w.write(config.getTitle()) ; w.write("</td>") ;
67       w.write("</tr>") ;
68       w.write("<tr>") ;
69       w. write("<td><label>") ; w.write(uriLabel) ; w.write("</label></td>") ;
70       w. write("<td>") ; w.write(config.getUri()) ; w.write("</td>") ;
71       w.write("</tr>") ;
72       w.write("<tr>") ;
73       w. write("<td><label>") ; w.write(encodingLabel) ; w.write("</label></td>") ;
74       w. write("<td>") ; w.write(config.getEncoding()) ; w.write("</td>") ;
75       w.write("</tr>") ;
76       w.write("</table>") ;
77     }
78     w.write("</div>") ;
79     w.write("<div>") ;
80     linkRenderer_.render(w,uiContentConfig, ADD_ICON + res.getString("UIContentConfig.button.new-entry"), NEW) ;
81     w.write("</div>") ;
82   }
83 }
Popular Tags