The common practice (and default option for the declarative approach) is to create one iterator binding per View Object in the Page Def file. But there's nothing to prevent us from defining several iterators in the PageDef's executable section for the same View Object. By default iterator binding binds to default row set iterator of the View Object. Iterator binding has RSIName attribute which allows us to bind to the named row set iterator of the View Object. When it could be an option? Let's assume we have a View Object with a bind variable in its query and we need to show on the same page two separate results of the query with different values of the bind variable:
And in our Page Def file we have two iterator bindings:select * from Employees where job_id = :job_idAs we know View Object can have many secondary row sets besides its main default row set which is used by default. Every row set can store its own set of bind variable values. The view links functionality is based on this feature. We are going to use it as well. So, we have our ViewObjectImpl class with two overridden methods:
protected void create() { super.create(); //Create Row Set for clerks and define value for the job_id bind variable ViewRowSetImpl rsClerk = (ViewRowSetImpl) createRowSet("ClerkRSI"); rsClerk.setExecuteParameters(null, new Object[] { new Object[] {"job_id", "ST_CLERK"}}, false); //Create Row Set for managers and define value for the job_id bind variable ViewRowSetImpl rsMan = (ViewRowSetImpl) createRowSet("ManRSI"); rsMan.setExecuteParameters(null, new Object[] { new Object[] {"job_id", "ST_MAN"}}, false); } public oracle.jbo.RowSetIterator findRowSetIterator(java.lang.String p1) { RowSetIterator rsi = super.findRowSetIterator(p1); if (rsi == null) //Probably we are looking for ClerkRSI or ManRSI return findRowSet(p1); return rsi; }
<iterator Binds="VEmp" RangeSize="25" DataControl="AppModuleDataControl" id="VEmpClerkIterator" RSIName="ClerkRSI"/> <iterator Binds="VEmp" RangeSize="25" DataControl="AppModuleDataControl" id="VEmpManagerIterator" RSIName="ManRSI"/>
That's it!
Hi,
ReplyDeleteIs it possible to create 'n' different iterator bindings for the same view object, where n is determined at runtime?
Thanks,
Sachin
Hi!
DeleteYes, it is. http://adfpractice-fedor.blogspot.com/2016/01/dynamic-iterator-binding-definition.html