Hello All
This post is about iterating over master and it's child view object using view link accessor, this is very basic thing of framework still some find (those who are starting with ADF) it difficult so I thought to write it here
Here I am using Departments and Employees table of HR Schema to create Master-Detail relation and due to view link relation, Department viewObject has view link accessor of Employees viewObject
This view link accessor containes rows for corresponding row of master (Departments) viewObject, It returns different rowset (list of Employees) for each record of Departments viewObject and we can programmatically access this view link accessor for each master record
Code in AMImpl to Iterate over Master and Detail view object records
import oracle.jbo.Row; import oracle.jbo.RowSet; import oracle.jbo.RowSetIterator; import oracle.jbo.ViewObject; /** * This is the method to iterate over Departments and corresponding Employees records */ public void iterateMasterDetail() { //Get Master ViewObject ViewObject deptVo = this.getDepartmentsView(); //Create iterator to iterate over master viewObject RowSetIterator rsi = deptVo.createRowSetIterator(null); while (rsi.hasNext()) { //Get Master ViewObject Row Row departmentsRow = rsi.next(); System.out.println("Department Name :" + departmentsRow.getAttribute("DepartmentName")); //Get Corresponding child viewobject accessor RowSet rs = (RowSet) departmentsRow.getAttribute("EmployeesView"); //Iterate over child viewObject rows for corresponding master record while (rs.hasNext()) { Row r = rs.next(); System.out.println(" Employee : " + r.getAttribute("FirstName") + " " + r.getAttribute("LastName")); } } //Close Master viewObject iterator rsi.closeRowSetIterator(); }
Add this method to client interface of Application Module and Run Application Module to check it
Output on log
Cheers :) Happy Learning
Good post
ReplyDeleteThank you for sharing this useful story.
ReplyDeleteI think your shared information is helpful to me and who are want update their knowledge, who want to started their career with Oracle ADF Online Training.
Thanks a lot for sharing this with us.. Keep on sharing like this informative post.
ReplyDeleteGood article. Thanks a lot for your helps.
ReplyDeleteThe accompanying kind of checks can be changed; finance checks, individual checks, checks made payable to an organization. check cashing near me 24 hours san diego
ReplyDelete