KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > content > explorer > renderer > html > TextContentRenderer


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.explorer.renderer.html;
6
7 import java.io.IOException JavaDoc;
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 /**
16  * @email: tuan08@users.sourceforge.net
17  * @version: $Id: TextContentRenderer.java,v 1.1 2004/07/16 09:51:34 oranheim Exp $
18  */

19 public class TextContentRenderer extends HtmlBasicRenderer {
20
21   final public void encodeBegin( FacesContext context, UIComponent component ) throws IOException JavaDoc {
22     UIContentViewer uiDisplayer = (UIContentViewer) component;
23     String JavaDoc content = uiDisplayer.getContent() ;
24     String JavaDoc 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