During this week I have faced an issue with LOV functionality when form is switched to Find mode. I got reply from Oracle, this issue is a bug in JDeveloper 11g. However, for those who need to use LOV components in Find mode in your current project, I will provide temporary workaround. Temporary, I hope until next JDeveloper 11g build.
You can download sample application, where LOV in Find mode works with applied workaround - LOVFindMode.zip. Developed sample contains one form with LOV component.
Its possible to switch this form to Find mode by pressing Find button.
Before describing workaround, I want to remind you about one trick I have noticed with LOV read-only View objects. When you generate Model layer using ADF Business Components From Tables wizard, KeyAttributes property for read-only LOV View objects is not set for some reason. As a result, after value in LOV popup is selected:
Nothing is returned back:
In order to fix this, open your read-only View object you are using for LOV:
And specify key attributes, you can do this directly in XML or through wizard:
Ok, now let's back to main topic of this post - workaround for LOV when form is in Find mode. At first, you can ask - where is the problem? Its easy to answer - select value from LOV popup for first time:
Press LOV icon second time, in order to change selected value - oracle.jbo.SQLStmtException: JBO-27122 is thrown:
For some reason, ADF constructs SQL statement with :vc_temp_1 bind variable, and this variable is not initialized:
oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT Employees.EMPLOYEE_ID, Employees.FIRST_NAME, Employees.LAST_NAME, Employees.EMAIL, Employees.PHONE_NUMBER, Employees.HIRE_DATE, Employees.JOB_ID, Employees.SALARY, Employees.COMMISSION_PCT, Employees.MANAGER_ID, Employees.DEPARTMENT_ID FROM EMPLOYEES Employees WHERE (( (Employees.JOB_ID LIKE :vc_temp_1 ) ) AND Employees.EMPLOYEE_ID = :1)
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
Its Oracle bug, and they will fix it next build, but for those who need to use LOV in Find mode with TP4, may be my workaround will be helpful.
While researching this problem, I have noticed that value from LOV is returned still correctly, even after exception is thrown. So, workaround is simple - just to hide generated exception. In 11g you can use centralized custom error handler class where reported exceptions can be managed.
This class should extend from DCErrorHandlerImpl class and should be registered in DataBindings.cpx file:
I'm catching generated exception in overrided reportException method and not reporting it, all other exceptions are reported as normal:
When this workaround is applied, you can open LOV popup when form is in Find mode as many times as you want - no error popup, and value from LOV is returned:
If you will check your server log, you will find entry that indicates information about catched but not reported exception: