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

4

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.

 

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.

 

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.

 

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.

Deployment takes place, the jar file is created.

 

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.

 

 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.

 

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

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.

 

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.

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:

 

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.

 

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.

 

After adding the Department, redeploy:

 

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!

 

 

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:

 

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

 

 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

 

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

 

 

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.

4 Comments

  1. I have done some ADF pages, now i have deploy ADF page in APPS, i don’t how to deploy adf page, can anybody tell me the process, how to deploy adf pages in apps?

  2. Hi,

    This has been quite helpful. Is it possible to call ADF pages from non-adf pages such as simple jsp? If yes, how do I achieve that?

    thanks!

  3. We had planned to make great use of the ADF Library feature, but we ran into a lot of trouble when we modified consumed libraries so we decided to abandon the use of adf libraries.

    We found several problems with the consuming project not seeing the modified contents of the jar. The problems took a variety of forms:
    * Invalid Jar URL errors which would result in .jspx and .jsff pages not opening
    * Dialog boxes that would appear with message “Error : Unable to find referenced object.” The referenced object in one case was an Entity Object, upon which View objects were built in the consuing application.
    * referenced taskflows would not be updated
    * Business component imports would be completely lost
    * several instances of an included jar would appear; not sure what problems this would cause. Documentation never mentioned how included jars are included in other jars.
    * mechanism for actually refreshing the consuming project to see the changed jar is not clearly documented. We tried several ways and all combinations and got variable results to no refresh at all.
    * not clear how to limit the items that go into a library — is it ALL ths contents in a project? What if you just want some of the artifacts?

    I’d like to see Oracle come out with clear instructions on how to work with ADF Libraries and come clean on the limitations. We won’t be using this ‘feature’ until the bugs are worked out.

  4. Hi, We have been using the ADF Library Jar feature of 11g, but have run into lot’s of problems with it.

    We often cannot get the consuming project to see changes in the ADF Library JAR no matter what we do.
    We try closing the application, refreshing everything possible–the filesystem connection, the application, twirling a cat three times over our heads, but nothing works.

    Do you have any tips to get the consuming project so see the changes?