Monday, April 26, 2010

Iterating a View Object using a secondary RowSetIterator

The recommended way to iterate a View Object is via a secondary RowSetIterator returned after calling createRowSetIterator() on the View Object. It is suggested to call reset() on the RowSetIterator before iterating it. This will move the currency to the slot before the first row. Iterate while calling hasNext() to check for next row availability and subsequently by calling next() to get the next row. When done, call closeRowSetIterator() to close the row set iterator. Failure to use a secondary RowSetIterator when directly iterating the View Object, could lead to end user confusion as the row set currency changes affecting the user interface.

Example:

         // in the context of the AppModuleImpl
       RowSetIterator iterator = viewObject.createRowSetIterator(null);

       iterator.reset();
       while (iterator.hasNext()) {
          Row row = iterator.next();
      
          // process the row here
       }

       iterator.closeRowSetIterator();


Context:

Application Module Implementation class
View Object Implementation class

 

 

No comments:

Post a Comment