Thursday, September 17, 2009

PropertyNotFoundException in Query Criteria LOV Component

Recently I have noticed strange errors while using LOV components in Query Criteria. Well, its known issue that you can't have two or more return elements in LOV component present in Query Criteria. But, in my case I was returning only one element - key attribute, and still I was getting error. This error was - javax.el.PropertyNotFoundException. Lucky me - I found the reason for this error, now my LOV is working properly in Query Criteria as well. I will describe what was a trick.

Download sample application - This sample demonstrates correct behavior - user selects value in LOV and performs search action:

Now, let's say developer forgot that LOV in Query Criteria can't return more than one attribute (in current JDeveloper 11g R1) and he adds second return attribute in LOV definition:

On runtime, for such LOV we will get this error:

Ok, thats fine, developer will realize his mistake and will go to remove second return attribute from the list, only one key attribute will remain present:

Second time developer will open the page, will select value in Query Criteria LOV, and again will get error. This time it will be different error - javax.el.PropertyNotFoundException:

Ok, now its strange. I found solution accidentally, by comparing my code with working one. Actually, what I found is that when you remove second return attribute from LOV definition, wizard removes only half of it. Another half of just removed attribute is still present in View Object source code. Here it is, highlighted code wasn't removed by the wizard, but it should be:

You can see its second attribute ManagerId declaration. Not a big deal, will remove it by hand and LOV in Query Criteria works again:

Conclusion - sometimes we can get a bug, just by removing bug. Be careful.

Spanish Summary:

En este post se describe como solucionar un bug de la herramienta que se produce cuando se intenta crear LOV (Lista de Valores) con 2 valores de retorno.

1 comment:

Marcus said...

Very useful post! It just happened to have the same issue myself and after spending several hours on that i have decided to google-it.
I have never thought about looking into the source code.
Thanks Andrejus!