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

5 comments:

  1. put please can you gave us the different between them ..


    thank you

    ReplyDelete
    Replies
    1. Example in #1 affect [change] current row in viewobject while example in #2 doesn't affect [change] current row in view object and you can make multiple RowSetIterator for the same viewobject

      Delete
  2. rsIterator.reset();
    لا حاجة لاستخدامها في الكود الثاني
    وهناك حاجة لها في الكود الأول
    كونك لا تضمن موقع الـ iterator

    تحياتي

    ReplyDelete

ADF : Scope Variables

Oracle ADF uses many variables and each variable has a scope. There are five scopes in ADF (Application, Request, Session, View and PageFl...