Friday 22 April 2011

Separate Database As Well As Table structure For Pages


It is some time required to use separate databases as well as separate table structure for separate pages. Or even in same page we can use separate databases. 
In ADF it can be achieved very easily. I am discussing here the simplest one. ApplicationModule in ADF can be compared with persistence units of JPA, not exactly though as ApplicationModule has a lot of  features that persistence units do not. I have compared with persistence unit as in ApplicationModule configuration also we provide the database information. 
In JPA we use different persistence units to define separate databases and use those persistence units when required.
Similarly here we will be defining to different application modules for two different connections. Now we will distribute the view objects accordingly. 


Please see the pictures 



In the example I have used two databases MGR and HR

I have configured MGR in  AppModule2 and HR in AppModule1

Now the view objects using MGR database will be configured in AppModule2 and  view objects using HR database will  be configured in AppModule2.


Now if you see the picture above you can see two separate data controls.

I have created two separate pages for separate data controls. untitled1.jspx uses AppModule1DataControl, untitled2.jspx uses AppModule2DataControl.

I have created one button in each of the pages for navigation between two pages, and configured the navigation in unbounded task flow. 



Now if I run the pages you can see that In First Page Data from HR database is being displayed while navigating to second page through the button, displays data from MGR database.





So you can easily achieve this using two different application modules for different databases. 

This feature can be achieved by different methods like using Factory Classes, setting  JDBC_DS_NAME etc..


But I wanted to use the simplest one.
Please comment........



No comments:

Post a Comment