Requirement: I have a demo.jspx page. On that page I have a three fileds: DepartmentId, ManagerId and EmployeeId. Here DepartmentId and ManagerId field are the af:inputText components and EmployeeId filed is the af:selectOneChoice component. Also there is an af:button named “Load EmployeeId”. Now after we pass values for DepartmentId and ManagerId and click on the named “Load EmployeeId” button it should load all the EmployeeId corresponding to the given DepartmentId and ManagerId.
Also, I want the solution to this requirement programmatically.
Solution: For solution to the above requirement, follow the steps as shown below:
Step 1: Create an Oracle ADF Fusion Web Application.
Step 2: Create a ViewObject through Custom SQL Query and name the ViewObject as “EmployeesVO”. The query used to create the ViewObject is shown below:
select employee_id,department_id,manager_id from employees
Step 3: Create an LOV for the EmployeeId attribute.
Step 4: Create a ViewCriteria “EmployeesVOCriteria” as shown below: Here I have created two binds variables: bvDepartmentId and bvManagerId.
Thus, the created ViewCriteria is shown below:
Step 5: Now we will create the View Accessors for the EmployeesVO as shown below:
Thus, the created ViewAccessors is shown below:
Step 6: Generate the EmployeesVOImpl class as shown below:
Step 7: Now we will generate the AppModuleImpl class as write the below code inside it:
Thus, the complete AppModuleImpl.java class code is shown below:
Now we will expose the Client Interface of the AppModule as shown below:
Thus, the Client Interface are shown below:
Step 8: Create a demo.jspx page. On that page drag and drop two af:inputText, one for DepartmentId and the other for ManagerId. Also drag and drop an af:button. Name the button as “Load EmployeeId” Create the binding for the af:inputText components and also create an actionListener for the af:button.
Now drag and drop EmployeeId attribute from EmployeesVO1 under the AppModuleDataControl as an af:selectOneChoice component.
Create a binding for the af:selectOneChoice. Thus the complete demo.jspx code is shown below:
Step 9: Now go to the MyBean.java and write the below code as shown below:
Thus, the complete MyBean.java code is shown below:
Step 10: Now open the demo.jspx page and go to the Bindings tab and create methodAction bindings. Thus, after adding the methodAction bindings the demoPageDef.xml look like below:
Step 11: Save All and run the application. Now when we pass DepartmentId=50 and ManagerId=100 and click on Load EmployeeId button we get the following EmployeeId populated in the EmployeeId selectOneChoice component as shown below:
Hence, the solution to our requirement.
If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.
Thanks & Regards,
Susanto Paul
498 total views, 2 views today