Wednesday Feb 25, 2009

Reusable ADF Library (RSSFeedReader): Updated to use the iterator component as opposed to the forEach.

In this blog entry I'll demonstrate the creation of a reusable component using JDeveloper/ADF 11g, Rome 1.0 RSS and Atom Utilities, and JDOM 1.0. First I'll provide the links to the required software.

Required Downloads:
JDeveloper 11g
Rome 1.0
JDom 1.1.2
FeedReader Application Workspace

Description of the FeedReader Application:
The simple description of the FeedReader Reusable Component is to create a Fusion Web Application (ADF) which creates both a Model and ViewController project for you. In the model project you want to add the rome.jar and jdom.jar files to your project libraries and classpath. The following steps outline the basic objects I've created for my application. is a simple object with setters and getters that describe the items to be displayed for a particular RSS Feed. The following image is a partial glimpse of the object. is an object with two methods processFeed which takes a url and creates a syndication entry that it then passes to the addEntry method which processes each entry 1 by 1 adding them to an ArrayList of Feed objects.

Also worth noting are a couple of test clients in the Model project, and, that you can take a look at. They were used to validate the data prior to creating the Data Control.

As for creating a Data Control I simply right clicked on the object and selected create Data Control. The Data Control is needed to expose the attributes and methods to the ViewController. Worth pointing out here is another aspect of the object. This object as used in exposes it's attributes through the Data Control.
Data Control

So now I'll move on to the RSSViewController project. The first thing to do is to create a ADF Bounded Task Flow and to drop a view component on it. The name of the bounded task flow is rsstask-flow-definition and the view is named rssFeedReader.jsff. After creating the bounded task flow I've added a parameter to it for the RSS Feed URL that I'll pass into it as you can see from the following image. The parameter name is RSSURL, it's a string and it is a required input.
ADF Bounded Task Flow

The next step is to set the NDValue for the argument being passed into the processFeed method to the same as that for the Value in the bounded task flow. But first, I must create the rssfeedReader.jsff jsf fragment. I do this by double clicking on the view in the bounded task flow and go with the defaults. I can now design the layout of the jsf fragment. Without going into all the details, I've basically created two outputText components for the titleHead and titleDesc by dragging those attributes from the FeedReader data control onto the jsf fragment. I've then used a For Each operation to iterate through the items of the supplied RSS Feed. Now that this is done, I can select the Bindings tab of the jsf fragment and select the rssFeedReaderPageDef | bindings | processFeed | arg within the Structure Pane and then in the Property Inspector, I set the NDValue to #{pageFlowScope.RSSURL}.
Rss Feed Reader JSF Fragment

I'm almost done. Now to create a deployment profile for the RSSViewController Project. This is done by double clicking on the RSSViewController project, selecting Deployment, selecting New, selecting ADF Library Jar File for the Archive Type, and give it an appropriate name. You should be able to go with the defaults from here but ensure that the Library Dependencies of the Model Project are selected.
Deployment Profile

Also in the RSSViewController Project is a untitled1.jsp jsf page to test out the new reusable ADF Library but I'll explain how to do this in a new workspace to simulate sharing this library with another developer perhaps.

The following image shows what the completed Application Workspace looks like.
Application Workspace

Sharing the Reusable ADF Library:
The first thing to do is to create a new Fusion Web Application Workspace as before. Ensure you've added the rome.jar and jdom.jar files to your project libraries and classpath as before. Then create a new File System Connection to the directory that you've copied the Reusable ADF Library to. After that, in your File System Connections under the Resource Palette, I simply right select the shared library and added it to my project. At this point, I can create a new jsf page and simply drag and drop the bounded task flow from the Component Palette onto my jsf page and supply a RSS Feed URL. Once I'm done with this I can run the page to test it out.
Feed Reader

Note: the jsf fragment is using the iterator component to iterator through the feed.

Feedback is appreciated.


I'm a Principal Product Manager in the JDeveloper/ADF product management team. I've been working with JDeveloper since 2004.


« April 2014