Friday, July 27, 2018
Programmatically switching LOV queries at run time
Programmatically switching LOV queries at run time
In todays post, Im Sharing a simple application which make use of ViewObjectImpl::prepareRowSetForQuery(ViewRowSetImpl vrs) on LOV source view object to alter the query at run time. LOV switcher is the ideal solution to switch LOVs at runtime. However there are odd scenarios where you may have N number of data sources for LOV which is known only at run time. This approach may work for you in such cases. [ The concept used in this post is inspired by a solution provided by Steve Muench in an internal discussion thread ]
Download
You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11.1.2.0.0 (11g R2) + HR Schema]
A glance at the implementation
1. Run test.jspx
2. Data source for LOV defined on ManagerId changes based on the values keyed in for DepartmentId field. If you leave Department empty, data is queried from EMPLOYEES table. If DepartmentId present for the row data for LOV is queried from DEPARTMENTS table for DepartmentId. The query switching is done programmatically from the over ridden prepareRowSetForQuery(...) method. Note that ViewObject definition doesnt change in the implementation, query alone changes.
Please see ManagerViewObjImpl::prepareRowSetForQuery(ViewRowSetImpl vrs) to learn more about the query switching details.
Download
You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11.1.2.0.0 (11g R2) + HR Schema]
A glance at the implementation
1. Run test.jspx
2. Data source for LOV defined on ManagerId changes based on the values keyed in for DepartmentId field. If you leave Department empty, data is queried from EMPLOYEES table. If DepartmentId present for the row data for LOV is queried from DEPARTMENTS table for DepartmentId. The query switching is done programmatically from the over ridden prepareRowSetForQuery(...) method. Note that ViewObject definition doesnt change in the implementation, query alone changes.
Please see ManagerViewObjImpl::prepareRowSetForQuery(ViewRowSetImpl vrs) to learn more about the query switching details.