Friday, 9 October 2015

Get the selected value of af:selectOneChoice in bean.

Requirement: I have a web page demo.jspx. The page has an af:selectOneChoice containing all the DepartmentName from the Departments table of the HR schema.. Whenever I select any DepartmentName in the af:selectOneChoice, it should display a the selected value in the bean.

Solution: To solve the above requirement follow the steps as shown below:

Step 1: Create an Oracle ADF Fusion Web Application.

Step 2: Create a ViewObject DepartmentsVO through Custom SQL Query for the Departments table. The query used to create the  DepartmentsVO  is shown below: 

select DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID from departments


Step 3: Create a List of Values for the DepartmentName column. This LOV should display all the DepartmentName.

Step 4: Create a demo.jspx page in the ViewController project of our application created in Step 1. From the AppModuleDataControl expand DepartmentsVO1, select DepartmentName attribute and drag and drop on the demo.jspx as an af:selectOneChoice.

Step 5: Create a valueChangeListener="#{pageFlowScope.MyBean.selectedValue}" for the af:selectOneChoice and make the autoSubmit="true". Thus the complete demo.jspx code is shown below:

Step 6: Go to MyBean and write the code as shown below:

Step 7: Save All and run the application.

Step 8: The ran application is shown below:
Step 9: Now when we select some value say (Human Resources) in the af:selectOneChoice component the corresponding value get printed in the bean as shown below:

Thus, the solution to our requirement.



Thanks & Regards,
Susanto Paul