Saturday, July 31, 2010

Select Once Choice inside ADF Query Referencing Parent table

Here By this sample I am explaining the way of using ADF SelectOneChoice inside Af:Query component as a reference to parents table. In that application I am using Employees as a child table and Departments as a parent table. I have used HR schema to create this sample application.

Create a Generic Application with the name of SocInADFQueryControlApp.


Create a project as with name ViewController. Select the ADF Faces for Project Technologies.

Enter the default package name for ViewController project.



Click on finish button. It will create a project in your application with the specified name.

Now Create a model project go to à new àGeneral àProjects àGeneric Project.

Click on Ok button.

Enter the name Model for model project. Select ADF Business Components from project technologies.

I have create ViewController and Model project using the Generic project, Because of better understanding why these are called ViewController and which technology supported by both the project. There is also a shortcut way to create ViewController and Model project either using the ADF Fusion Web Application or using Project creation wizard for ViewController and Model project.

Now let’s create Business component for Model project. Select Model Project click on New à Business Tier à ADF Business Component à Business Components from Table.
Create a connection to oracle database.

Select the Employees and Departments table.

Create the updateable view if required else skip it and create Read-Only view object.

Provide App Module name as SampleAppModule.

Skip Business Components Diagram as it is not required.

Click on the finish button.

Once you have clicked the finish button it will create Entity Object, View Object, Association, View Links and App Module.

Create a webpage. Select the ViewController project; go to à new à Web Tire àJSF à JSF Page.


Enter the page name as main.jspx; I have created this page using the Oracle Three Column Template. You can select whatever template you want or can select blank page.

Select the Employees View, go to à Attributes àSelect the DepartmentId Column.


Click on + icon and DepartmentView1 as a reference.
Click on + icon and DepartmentView1 as a reference.
Select the list Attribute DepartmentId.

Go to UI Hints Select the DepartmentName that will appear in the combo box, to make the component combo box select the Default List Type Choice List.

Now select the query and the view criteria.

Click on ok button.

Select the criteria from Employees View Object drag drop it to page. Select the Query à Adf Query panel with Table.

Enable Row Selection, Filtering and sorting.

Surround table with panel collection and select style Class as AFStretchWidth.

Change the result component id to panel collection id.

Once you deploy and run application screen look like:



No comments:

Post a Comment

Thanks for your valuable comment. You comment will go live soon.