Saturday, June 11, 2011

ADF BC Application Module Data Control Hints for JDeveloper 11g R2 ADF Libraries

I got a question from blog reader, based on my previous post - How To Reduce Database Connections and Reuse ViewController Layer. This post is based on ADF library dependencies with ADF BC objects - library is not imported directly into project, but is accessed through proxy library with implemented root Application Module - to reduce opened database connections. However, same application fails to work on design time in JDeveloper 11g R2 (latest release from this week) - IDE wizard returns error about missing Data Control objects. It works on runtime though, means there are no issues with ADF runtime, its something with IDE. However, I would not claim this as IDE bug, I believe that IDE applies best practice approach for how we should consume ADF libraries. There are few hints to keep in mind, when working with latest JDev release and consuming ADF libraries with ADF BC objects (specifically Application Modules) inside. This applies only to those cases, when you are reusing Application Modules from ADF Libraries.

Download sample application - ADFBCLibsSharedApp.zip. This sample contains three ADF applications developed with JDev 11g R2 - SharedLibsApp (ADF BC reusable components), ADFBCLibsImportsApp (demo how to consume ADF BC libs on ViewController), ADFBCLibsImportsModelApp (demo how to consume ADF BC libs on Model).

SharedLibsApp contains one project with reusable ADF BC objects and Application Module - LibModule, both packaged into reusable ADF library. This library is not referenced directly from other projects, but through RootLibModule AM (another project), which is also compiled into ADF library (same scenario as from blog mentioned above):


Root module library contains root Application Module, it nests modules from another ADF libraries:


Consumer application imports root module library:


However, what happens in newest JDev release in this scenario, for example when navigating through Page Definition elements (referenced from imported nested library through root module) - Data Control iterator is not found (this error is reported in the loop and practically kills JDev, you need restart). This happen for ADF apps implemented with previous JDev versions, its not current IDE bug:


From project structure we can see, there is Library Dependency file - it points to these libraries not imported directly, but referenced from directly imported ones (in our case it points to adflibModelLib):


If we open Data Control tab and try to expand nested module, it also fails to be loaded:


This clearly indicates that, ADF Library dependency fails to bring dependent library into context, its why we can't see it through Data Control.

In order to fix this, you only need to add required library dependency directly:


Now restart JDeveloper - good news JDev 11g R2 restarts really fast, so you don't need to wait that much as before.

No ADF Library dependency file available anymore:


Data Control is constructed correctly this time:


Page Definition objects are loaded correctly as well and are accessible:


Page is loaded on runtime as well:


This case is clear now, lets explore one more scenario - ADF library with ADF BC imports into Model project. Let say our ADF library contains two Application Modules:


Library is imported into Model project and both Data Control instances are appearing correctly:


However, once we enable ADF BC support for local Model project:


Data Control instances are disappearing:


If we double check imported objects, both AM's are present:


It may look wrong for you, but I would assume its correct behavior in JDev 11g R2, even same was working in previous release. If we import AM instances into ADF BC Model project, it would not be a best practice to reference different AM's separately through Data Control - lots of database connections would be opened. Instead of exposing imported AM instances directly through Data Control, we can nest them into local AM:


Now both imported AM's are accesible from Data Control through root local AM:


If you dont want badly to nest imported AM instances into local AM, there is still a trick you can apply - but I don't recommend it. You can open Model.jpx file and add imported AM instance there manually:


However, this would be a bad practice - Model.jpx gets regenerated quite often automatically and you will loose your manual changes. And as I already explained, its good to nest imported AM's, to prevent large number of open database connections. When Model.jpx is changed manually, imported AM instance becomes visible - until Model.jpx is not regenerated by JDev:


9 comments:

giovanni said...

Hi Andrejus,
if i understand the second approach is the best to use in jdev 11gR2

So I tried to upgrade a project migrated from 11.1.1.5 and dataControls detail are visible but
when i rebuild the viewControl project i see that i lost all java classes references
let me explain.. in to my class bean i see all class packages imported without apparent errors,
but when i compile the view control the compiler-log tell me many Error type "package does not exist"
you think that I need to include the adf library jars in the classpath of my view control project,
even if they are presents in the project model?
(i inform you that project model.jpr is present in my view Control project property dependencies)
thank you for your time
Gio

Andrej Baranovskij said...

Yes, second approach is recommended.

Andrejus

giovanni said...

I found one solution.
Add in viewController classpath the Model ADF Library Dependencies.
Thanks again
Gio.

Andrej Baranovskij said...

Make sure there are no duplicate classes created after packaging.

Andrejus

ಆಶ್ವಿನ್ ಆಲ್ಮೆಡ (Ashwin Almeida) said...

Hi Andrejus,

I have a application scenario, where I have to perform data operations(create,delete/update, select) from 2 sources, 1 from ldap using oim api, other from DB using adf bc.

my problem is calling the adf bc from the managed bean of the taskflow.

what is the best way to call a adf bc app module in a bean, also how can i do these two data operations in a single transaction.

sheryf said...

I have AM1 which has client interface methods, i nested AM1 into AM2 but the AM1 client methods cant be seen in the data controls palette. When i run the AM2 instance for testing, the client methods for AM1 were seen as expected.

how can i expose AM1's client methods in AM2 nesting? or do i have to call these methods programmatically? the applicationmoduleimpl.invokemethod doesnt seem to have enough documentation for its usage. help!!

Anonymous said...

Thanks for putting this together Andrejus! As I learn 11g, I'm sure I'll be visiting your blog quite often.

-Wes

Anonymous said...

Hi Andrejus

I archive to jar my Application module then set lib class path the jar. Also setted to Nested application module to root application module but load view object then follow error occur.

oracle.jbo.NoObjException: JBO-25003: Object OrganizationVO of type View Object is not found.


The View object is updateable view object and read only view object is ok

How to resolve it?

thanks

Sruk said...

Hey Andrejus,

thank you for sharing your experience. I just want to confirm that issue is still resolved this way in 12c, even though I noticed some anomalies in which JDeveloper does not behave consistently in showing data control from library