KickJava   Java API By Example, From Geeks To Geeks.

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


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 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 JavaDoc;
16
17 /**
18  * @email: tuan08@users.sourceforge.net
19  * @version: $Id: ContentPreviewRenderer.java,v 1.1 2004/07/16 09:51:34 oranheim Exp $
20  */

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 JavaDoc {
26     ResponseWriter w = context.getResponseWriter() ;
27     UIContentEditor uiEditor = (UIContentEditor) component ;
28     String JavaDoc content = uiEditor.getContent() ;
29     String JavaDoc 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