ADF : Dynamic View Object

Today I want to write about dynamic view object which allow me to change its data source (SQL query) and attributes at run time.

I will use oracle.jbo.ApplicationModule :: createViewObjectFromQueryStmt method to do this issue.

I will present how to do this step by step

Create View Object and Application Module
 
1- Right click on Model project and choose New

2- Choose from left pane “ADF Business Component” , then from list choose “View Object” and click “OK” button

3- Enter “DynamicVO” in “Name” and choose “Sql Query” radio button and click “Next” button.

4- Write in Select field “select * from dual” and click “Next” button until reach Window “Step 8 of 9″

 
5- Check “Add to Application Module” check box and click “Finish” button.

Implement Changes in Application Module

1- Open application module “AppModule”, then open Java tab and check “Generate Application Module Class AppModuleImpl” check box


2- Open AppModuleImpl.java Class and Add the below method for dynamic view object

   public void changeDynamicVoQuery(String sqlStatement) {  
     ViewObject dynamicVO = this.findViewObject("DynamicVO1");  
     dynamicVO.remove();  
     dynamicVO = this.createViewObjectFromQueryStmt("DynamicVO1", sqlStatement);  
     dynamicVO.executeQuery();  
   }  

3- Open “AppModule” then open Java tab and Add changeDynamicVoQuery method to Client Interface

Test Business Component
 
1- Right click on AppModue in Application navigator and choose Run from drop down list.

2- Right click on AppModule in left pane and choose Show from drop down lsit

Write “Select * from Emp” in sqlStatement parameter
Click on Execute button, The result will be Success .

3- Click double click on DynamicVO1 in left pane, it will display the data of DynamicVO and display data which I entered “Select * from Emp” before not “Select * from dual” that was used in design time of view object.

 
To use dynamic view objects in ADF Faces, you should use ADF Dynamic Table or ADF Dynamic Form.

You can download sample application from here

Reference: ADF : Dynamic View Object from our JCG partner Mahmoud A. ElSayed at the Dive in Oracle blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

Leave a Reply


− 4 = two



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close