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

How to Pass Parameters to ActionListener in ADF

In some cases, it is required to pass a value to ActionListener of ADF Button. The method that can be invoked by actionListeners has only...