KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > rss > renderer > html > RssRenderer


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.rss.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.faces.FacesConstants;
11 import org.exoplatform.faces.core.component.model.Parameter;
12 import org.exoplatform.faces.core.renderer.html.HtmlBasicRenderer;
13 import org.exoplatform.portlets.rss.component.*;
14 import java.io.IOException JavaDoc;
15 import java.util.ResourceBundle JavaDoc;
16
17 /**
18  * @email: tuan08@users.sourceforge.net
19  * @version: $Id: RssRenderer.java,v 1.4 2004/09/02 19:26:10 benjmestrallet Exp $
20  */

21 public class RssRenderer extends HtmlBasicRenderer {
22
23     private static Parameter[] updatePortletParams =
24     { new Parameter(FacesConstants.ACTION , UIRss.UPDATE_ACTION) };
25
26   final public void encodeBegin( FacesContext context, UIComponent component ) throws IOException JavaDoc {
27     ResponseWriter w = context.getResponseWriter() ;
28     String JavaDoc baseURL = context.getExternalContext().encodeActionURL(null) ;
29     ResourceBundle JavaDoc res = getApplicationResourceBundle(context.getExternalContext()) ;
30     UIRss uiRss = (UIRss) component ;
31     Channel channel = uiRss.getChannel() ;
32     Item[] items = channel.getItems() ;
33     w.write("<div class='UIRss'>") ;
34     w. write("<div class='title'>");
35     w. write(channel.getTitle());
36     w. write("</div>");
37     w. write("<div class='body'>");
38     w. write("<ul>");
39     for (int i = 0; i < items.length ; i++ ) {
40       w. write("<li style='text-align: justify'>") ;
41       w. write("<a HREF='" +items[i].getLink() + "'>");
42       w. write(items[i].getTitle());
43       w. write("</a>") ;
44       w. write("<div class='description'>") ;
45       w. write(items[i].getDescription()) ;
46       w. write("</div>");
47       w. write("</li>");
48     }
49     w. write("</ul>");
50     w. write("</div>");
51     w. write("<div class='footer'>");
52     linkRenderer_.render(w, uiRss, res.getString("UIRss.img.reload-icon"),updatePortletParams);
53     w. write("</div>");
54     w.write("</div>");
55   }
56 }
Popular Tags