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.
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.
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
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:
Refresh the File System connection in the Resource Catalog to see the reusable wares on offer:
- Some more details on ADF Placeholder Data Control (rebind component, master detail, load sample data from CSV file)
- ADF 11g Placeholder Data Control – for off line demonstration of application and/or rapid UI prototyping without a need for a business service
- Spring and Oracle ADF – registering a POJO Spring JDBC based Business Service as Data Control
- Building ADF Faces Tree based on POJOs (without using the ADF Tree Data Binding)
- ADF: (Automatic) Partial Page Rendering across Taskflows
- ADF client-side architecture – Select All
- ADF DVT: Analyzing Financial Position of the European Football (Soccer) Leagues using Treemap
- ADF DVT – Scaling TreeMap components for comparisons across masters and categories
- ADF DVT: Using the Tree Map visualization component – to compare relative sizes and distributions
- ADF DVT: Using the Timeline component to visualize the recent history of an RSS feed
- ADF: (re-)Introducing Contextual Events in several simple steps
- ADF DVT Speed Date: Interactive Bubble Graph
- Out of the box usage of ADF DVT Scheduling Gantt Chart to report Database Query Results using stacked bar charts per time period
- ADF DVT Speed Date : Meeting The Hierarchy Viewer