1 5 package org.exoplatform.portlets.content.explorer.renderer.html; 6 7 import javax.faces.component.UIComponent; 8 import javax.faces.context.FacesContext; 9 import javax.faces.context.ResponseWriter; 10 import org.exoplatform.commons.utils.HtmlUtil; 11 import org.exoplatform.faces.FacesConstants; 12 import org.exoplatform.faces.core.component.model.Parameter; 13 import org.exoplatform.faces.core.renderer.html.SimpleFormRenderer; 14 import org.exoplatform.portlets.content.explorer.component.UIContentEditor; 15 import java.io.IOException ; 16 17 21 public class ContentPreviewRenderer extends SimpleFormRenderer { 22 private static Parameter[] editCurrentParams_ = 23 { new Parameter(FacesConstants.ACTION , UIContentEditor.EDIT_CURRENT_CONTENT_ACTION) }; 24 25 final public void encodeChildren( FacesContext context, UIComponent component ) throws IOException { 26 ResponseWriter w = context.getResponseWriter() ; 27 UIContentEditor uiEditor = (UIContentEditor) component ; 28 String content = uiEditor.getContent() ; 29 String mime = uiEditor.getContentType() ; 30 if ("text/plain".equals(mime)) content = "<pre>" + content + "</pre>" ; 31 else if ("text/xml".equals(mime)) content = "<pre>" + HtmlUtil.showXmlTags(content) + "</pre>"; 32 w.write("<table width='100%'>"); 33 w. write("<tr>"); 34 w. write("<td style='padding: 10px 10px 10px 10px' valign='top'>"); 35 w. write(content); 36 w. write("</td>"); 37 w. write("</tr>"); 38 w. write("<tr>"); 39 w. write("<td align='center' valign='center'>"); 40 linkRenderer_.render(w,uiEditor, "Back" , editCurrentParams_) ; 41 w. write("</td>"); 42 w. write("</tr>"); 43 w.write("</table>"); 44 } 45 } | Popular Tags |