Creating an ADF URL Service DataControl for binding a File or Servlet/JSP service and using it in an ADF Faces Web Application

0

Looking through the list of new features for JDeveloper 10.1.3.2 yesterday I suddenly noticed a feature that was not new at all, but that had so far escaped my notice: the URL Service Data Control, that allows us to define a ADF Model Data Control for URL Services, such as files (CSV, XML, etc.) that can accessed through a URL and also Servlets and JSPs that return simple, textual data such as XML. In this article, I take this feature for brief spin. My objective: publish in a web page in a table layout the contents of a CSV file that I know lives somewhere on the internet (actually, my own laptop) behind a URL.

This demonstration proves once again how the ADF Model Data Controls allow us to develop a web page on top of Data Controls without any knowledge of the underlying Data Control implementation. Developing the webpage is no different for this URL Service Data Control from what it is like with a Database Data Control.

 

The result when we run the web application looks like this:

....
I have created a new JDeveloper Application, Technology Template of JSF and ADF BC (although I will not actually create any Business Components, it creates a Model project for me, which is handy).

In the Model project I go to the New Gallery to select the option:
 

 

 

The wizard opens where I can name the Data Control. This name will appear later on in the Data Control palette.
 

 

 Now the underlying Http Connection details: since the file is not secure in any sense, all I need is the URL where file is available. (for development ease, I have included the file in the Public_Html directory of the ViewController project in this very application). 

Navigate to the last step in the wizard, where we confirm that this is indeed a Comma Separated Values file.

 

 The new DataControl is automatically added to the Data Controls palette:
 

 

 I have created new JSF JSP page. Now I drag & drop the Employees data control’s Return collection onto my JSF page, as a read only table:

 

The JSP editor now looks like this: 

 

When we run the web application, here is what we see: 

 

The contents of the emps.csv file is read  by the Data Control’s underlying Http Adapter and served to the ADF Table in the proper, file/url/http independent data format. Note that the sort operation, a feature of the ADF Table, is also available for this data collection read from the url. Here I sort by City:

 

I was very curious as to how the configuration of this Data Control takes place. Especially for when it comes to deployment, one should know how to configure these Data Controls. The first stop is the DataControls.dcx file where the DataControl is specified as an AdapterDataControl, based on the CSVDCDEF class, returning the Employees BeanClass and based on the Connection EmployeeFromFile. Now where the hack is that Connection defined? I could not find it anywhere in JDeveloper, not even through a Search in All Files.

 

Inspecting the file system quickly made things clear: the connections.xml file in the .adf \meta-inf directory contained the connection definition, complete with the URL. So that is where I can configure this particular DataControl:

Share.

About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director for Fusion Middleware. Consultant, trainer and instructor on diverse areas including Oracle Database (SQL & PLSQL), Service Oriented Architecture, BPM, ADF, Java in various shapes and forms and many other things. Author of the Oracle Press book: Oracle SOA Suite 11g Handbook. Frequent presenter on conferences such as JavaOne, Oracle OpenWorld, ODTUG Kaleidoscope, Devoxx and OBUG. Presenter for Oracle University Celebrity specials.

Comments are closed.