May, 2010

...now browsing by month

 

JDev 10.1.2 Portlet that consumes RSS Feed

Tuesday, May 4th, 2010

Today, I created several servlets that generate RSS feeds from dynamic data in tables. In order to view the data in another page, it made sense to use a simple portlet. When creating the definition, just make sure that you allow for a single parameter, the feed URL, when defining the provider.

This seems to work fairly well, and I have already created several versions that display the data differently. When I get time, I hope to update that code using CSS to format the data, but that will wait for another day.

<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="oracle.portal.provider.v2.ParameterDefinition"%>
<%@page import="oracle.portal.provider.v2.render.PortletRenderRequest"%>
<%@page import="oracle.portal.provider.v2.http.HttpCommonConstants"%>

<%
  PortletRenderRequest pReq = (PortletRenderRequest) request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);
  ParameterDefinition params[] = pReq.getPortletDefinition().getInputParameters();
  String sURL = "";
  try {
    sURL = pReq.getParameter("p_url");
  
    if (sURL == null || sURL.equals("")) {
      System.out.println("sURL could not be determined");
      sURL = "http://www.weather.com/weather/today/Castle+Rock+CO+80104?cm_pla=city_page&cm_ite=cc&site=city_page&cm_ven=LWO&cm_cat=rss&par=LWO_rss";
    } 
  } catch (Exception e) {
      System.out.println("Error:" + e.getMessage());
  }

  out.println(rssfeedconsumer.mypackage.RSSReader.getFeed(sURL));
%>        

You may be wondering where the java code is that generates the actual feed. I can post that later, but for those that want this now, here is a link from the site that I based my code from.

Creating an RSS Feed