Using the ADF URL Data Control to Read RSS Feeds

An Oracle JDeveloper How To Document
Written by Dana Singleterry, Oracle
July, 2008

Introduction

The Oracle ADF Framework includes a Data Control for URL Services (a.k.a URL Service Data Control). The URL Service Data Control provides the ability to access files (CSV, XML) through a URL. You can also utilize this Data Control to access Servlets and JSPs that return simple, textual data such as XML data. In this How To, the URL Service Data Control will be used to access the JDeveloper RSS News feed and present that data within a Rich Client Interface. You will need JDeveloper 11g, available from OTN, to give this a try. Also provided is the Application that is utilized in this How-To.

Create a Fusion Application

Create a "New Application" and name it appropriately.

Select "Fusion Web Application (ADF)" from the Application Template. This creates a Model and ViewController project.

Provided is an xsd ( jdevnewsrss.xsd) for the jdeveloper news feed. If you are using another  rss feed, you will have to provide your own xsd.

Create a simple jsp page and name it appropriately.

You're now ready to create a url service data control.

Your Application should consist of two projects, Model and ViewController.

Create a URL Service Data Control

Create the URL Service Data Control by right selecting on the Model Project and selecting "New" from context. 

Select "Business Tier->Data Controls->URL Service Data Control".

Specify a unique name for the data control and selct Next in step 1 of 5.

In Step 2 of 5, provide the "URL Endpoint". In the case of the JDeveloper News Feed, it is -> http://www.oracle.com/technology/products/jdev/jdeveloper_news.xml

In step 4 of 5, you must select the data format of the data source and specify the properties. So for "Data Format:", choose "XML" and provide the XSD URL for the XSD that you've created to validate your RSS feed against. We've provided the xsd so place it somewhere on your filesystem as indicated above.

Results of completing the URL Data Service Control Wizard. Now Test the URL Connection.

Results of Testing the URL Connection. Select Finish to complete the wizard.

The application Data Contol that you created and it's xml representation are as viewed in the Application Navigator in the image above.

Use the Data Control to display the RSS Feed in a table.

Select the "item" element under "rss->channel" from you Data Control and drag it onto your jsp page.

Select "Tables->ADF Read-only Table..." from context.

Accept the defaults and save your work. You're now ready to test the application you've created.

Run the Application

Now that you've completed the creation of the URLDataControl and created a Master Table to display the RSS feed within your jsp page, you can run the application to test your work. Right click on the jsp page you've created and select run from context. This will run your application in the integrated JEE application server.

As you can see,  the results of creating your URL Service Data Control and and a Read-only Table to display the data is produced as illustrated in the image above. The one problem here is that the formatting of the data is not very useful. If you're interested in doing more and reformatting this information to make it more readable then read on to experiment with the "ADF For Each Operation".

Additional Information: Formatting the Results...The ADF For Each Operation

Note: Since this tutorial has been created, we changed our recommendation to use af:iterator instead of af:forEach component. Please consider using the af:iterator when building your application.

Now ....drag and drop an ADF For Each Operation from your Components Pallette onto the jsp page just beneath you ADF Read-only table.

Double-click the forEach operation within you jsp page to modify the forEach properties.

Select the "Items->Expression Builder...."

Select "bindings->item->rangeset" and "^Insert Into Expression". Select OK to complete the Expression Builder.

Additional formatting components that you may want to look into that are utilized are are a goLink and output text. So, for example, here we apply the link that is returned to the title and then beneath that we output the description detail for each item record that is retrieved from the JDeveloper RSS News Feed.

          <h:panelGrid columns="1">
            <af:goLink text="#{row.title}" destination="#{row.link}"
                       inlineStyle="width:100%; font-weight:bold; color:ActiveCaption;"/>
            <af:outputText value="#{row.description}"
                           inlineStyle="color:Black;"/>
          </h:panelGrid>

Results of  testing your application  and viewing your data formatting work.

Conclusion

In this How-To we've demonstrated the creation of a URL Service Data Control and formatting of that output using the ADF For Each Operation. Additional formatting tips such as the ADF goLink and output text components are also demonstrated. Note that the URL Service Data Control can also be used to access CSV filetypes.

false ,,,,,,,,,,,,,,,,