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
Reference:
Oracle® Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework 11g Release 1 (11.1.1) Part Number B31974-05 [Section 9.7.6 What You May Need to Know About Programmatic Row Set Iteration]
Indeed the preffered way. :)
ReplyDeleteAnother way is the one below
but it will lost the current row, so you will have problem if you use the VO to display data. Otherwise you do not really care.
// in the context of the AppModuleImpl
RowSetIterator iterator = viewObject.getRowSetIterator(null);
while (iterator.getCurrentRow() != null) {
Row row = iterator.getCurrentRow();
// process the row here
iterator.next();
}
iterator.reset();
Spyro, definitely not recommended :(. Please refer to section 9.7.6. of the B31974-05 documentation - link is referenced on the post.
ReplyDeleteTrue :(
ReplyDeleteHi Nick,
ReplyDeleteThanks for this post.
If I'm not mistaken, this provides method to iterate over current RowSet.
How about iterating over all rows?
Thanks.
Hi Ilya,
ReplyDeleteI am not sure what you are referring to... The above technique will let you iterate over all the rows.