01 July, 2012

ADF : Iterate ViewObject


In some cases you want to iterate through ViewObject, To do this you have two choice
1- Iterate through ViewObject and change current row in ViewObject
2- Iterate through ViewObject without changing current row

I will present a code snippet  for every one
Assume that you will do this code in ApplicationModuleImpl class


1- Iterate through ViewObject and change current row in ViewObject

     ViewObjectImpl viewObject = getAllAdvisorView();  
     viewObject.executeQuery();  
     while (viewObject.hasNext()) {  
       Row row = viewObject.next();  
       // DO what do you want in Row  
     }  

2- Iterate through ViewObject without changing current row

     ViewObjectImpl viewObject = getAllAdvisorView();  
     RowSetIterator rsIterator = viewObject.createRowSetIterator(null);  
     rsIterator.reset();  
     while (rsIterator.hasNext()) {  
       Row row = rsIterator.next();  
       // DO what do you want in Row  
     }  
     rsIterator.closeRowSetIterator();  

Thanks
Recommended Post Slide Out For Blogger