Building a repository of reusable ADF artefacts using ADF Libraries – for example: a reusable Placeholder Data Control

Reusability – and from there higher productivity and easier maintenance – is one of the key themes for ADF 11g. There are several important new concepts introduced in this new release, including Task Flows, Declarative Components, Page Templates and Page Fragments. It is of course one thing to create artefacts that are potentially reusable.  It is quite another to organize those artefacts and make them available across projects and applications. And that is where the ADF Library comes in. It is the vehicle for packaging up fairly small scoped reusable elements in JAR files that are then made available in the Resource Catalog.

It turns out to be incredibly easy to create an ADF Library – and to reuse one. I will demonstrate that in this article, by turning a Placeholder Data Control that provides off line data binding opportunities for applications using DEPT and EMP. I have created a Placeholder Data Control with Department and Employee Data Types and sample data taken from the SCOTT schema. (see Some more details on ADF Placeholder Data Control (rebind component, master detail, load sample data from CSV file)  for details on how to do that). Now I want to make that Placeholder Data Control available to any project I create where Dept/Emp data is useful and on line access to the database may not be available.

Note: it also makes sense for me to create an ADF Library with the HrmService ADF BC Application Module with the Entity and View Objects against the EMP and DEPT table that I so frequently use – and so frequently recreate because my personal reuse is organized so lamely! ....

We begin in the project that contains – noting but – our Placeholder Data Control.

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary001

 

In order to package the project contents in an ADF Library, we first have to create an ADF Library Deployment Profile. Go to Project Properties. Select the Deployment node. Select ADF Library Jar File as the Archive Type. Provide a meaningful name for the archive.

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary002 

Press OK. In the Edit window, under JAR options, specify the location on the file system where jar should be created. This could be a shared directory, making the JAR immediately available to other projects. You could also consider loading the jar after deployment to a WebDAV server or Maven Repository. In my case, I have decided to collect all ADF Libraries in directory called projects\ADFLibraries.

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary003 

Press OK. 

Now from the context menu on the project node, select the Deployment Profile that was just created, and deploy the project’s contents to an ADF Library.

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary004

Deployment takes place, the jar file is created.

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary005 

We are done – for now – in the project where we create/maintain the reusable Placeholder Data Control.

Reusing stuff from an ADF Library

I have created a brand new application, Fusion Web Application technology template. It is quite empty at this stage. I want to rapidly develop a page with a form that presents Department data.

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary006 

 I have learned about the availability of this handy, off-line Data Control that provides Department data without the need for a backing database. And apparently that Data Control has been published in library that I can access through the Resource Catalog.

Let’s turn our attention to the right side of the screen for a moment. The Resource Palette. I need to create a new File System connection, as the ADF Libraries are located somewhere on the file system.

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary007 

I provide a name for the connection as well as the directory this connection is to :

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary008

When I close the dialog and open the new connection in the browser, I find the ADF Library I created earlier and inside it this infamous Data Control.

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary009 

In order to actually use that Data Control in my own brand new Web Application, I need to add it to my project. Note that this does not mean copying the Data Control’s definition – it really only means adding a reference to the ADF Library to the project.

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary010

The Data Control palette for the brand new and previously quite empty application now shows up with the Department data type inside the Placeholder Data Control:

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary011 

I now drag the Department node to a new JSF page, drop it as a Read-Only ADF Form and run the page. In 17.8 seconds, I see the data that was created as sample data in the Placeholder Data Control’s Department Data Type, then deployed as an ADF Library and included in an entirely different project.

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary012 

Maintaining the ADF Library

Like I said before, we did not copy any stuff from the Jar file to the consuming project – all we did was add a reference to the library. If we now make a change to the Placeholder Data Control, for example add a new Department in the Department Data Type’s Sample data, we can redeploy the project to the ADF Library and that change should be visible in all projects that consume the Library.

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary013 

After adding the Department, redeploy:

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary014 

Go back to the consuming application. Refresh the Connection. Now open the Data Control and  look at the Sample Data for the Department Data Type: the new Department has arrived!

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary015 

 

Creating an ADF Library for the HrmService

Just like I have created the ADF Library for the Placeholder Data Control, I will create one for the HrmService ADF BC Application Module on top of the DEPT and EMP tables in the Scott schema.

Go to the project properties, select the Deployment node and create a new deployment profile:

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary016

 

Specify the target directory – the directory where I collect all ADF
libraries

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary017

 

 Press OK a couple of times. Then from the context menu on the project node, select the deploy according to this new deployment profile option:

step 3

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary018

 

Refresh the File System connection in the Resource Catalog to see the reusable wares on offer:

 

Building a repository of reusable ADF artefacts using ADF Libraries - for example: a reusable Placeholder Data Control adflibrary019

 

4 Comments

  1. Rama Krishna January 22, 2011
  2. RR May 20, 2009
  3. Todd March 14, 2009
  4. Todd February 25, 2009