1 5 package org.exoplatform.portlets.content.explorer.renderer.html; 6 7 import java.io.IOException ; 8 import javax.faces.component.UIComponent; 9 import javax.faces.context.FacesContext; 10 import javax.faces.context.ResponseWriter; 11 import org.exoplatform.commons.utils.HtmlUtil; 12 import org.exoplatform.faces.core.renderer.html.HtmlBasicRenderer; 13 import org.exoplatform.portlets.content.explorer.component.UIContentViewer; 14 15 19 public class TextContentRenderer extends HtmlBasicRenderer { 20 21 final public void encodeBegin( FacesContext context, UIComponent component ) throws IOException { 22 UIContentViewer uiDisplayer = (UIContentViewer) component; 23 String content = uiDisplayer.getContent() ; 24 String mime = uiDisplayer.getContentType() ; 25 if ("text/plain".equals(mime)) content = "<pre>" + content + "</pre>" ; 26 else if ("text/xml".equals(mime)) content = "<pre>" + HtmlUtil.showXmlTags(content) + "</pre>"; 27 ResponseWriter w = context.getResponseWriter() ; 28 w. write("<div style='width: 100%; margin: 5px;'>") ; 29 w. write(content) ; 30 w. write("</div>") ; 31 } 32 } | Popular Tags |