1 5 package org.exoplatform.portlets.content.display.renderer.html; 6 7 import java.util.* ; 8 import java.io.IOException ; 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 21 public class ContentConfigRenderer extends HtmlBasicRenderer { 22 23 final public static String 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 { 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 deleteButton = res.getString("UIContentConfig.button.delete") ; 39 String editButton = res.getString("UIContentConfig.button.edit") ; 40 String modifyButton = res.getString("UIContentConfig.button.modify") ; 41 String titleLabel = res.getString("UIContentConfig.label.title") ; 42 String uriLabel = res.getString("UIContentConfig.label.uri") ; 43 String encodingLabel = res.getString("UIContentConfig.label.encoding") ; 44 Map map = uiContentConfig.getAllConfigs() ; 45 String 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 |