Saturday, July 25, 2009

LOV Query Validation in Query Criteria

I have noticed in latest JDeveloper 11g release, LOV components present in Query Criteria are not validated by default. In order to make it work correctly, you need to change attribute property in View Object.

Here I'm describing how to validate LOV components in Query Criteria. Download sample application - LOVQueryValidation.zip.

By default, if you enable LOV's in Query Criteria, there is no validation applied. For example, if to type values not available in LOV list and press Tab button to navigate out of LOV, invalid value is accepted and LOV popup is not raised:


Definitely you can notice that auto submit action is not done - its why validation is not invoked. In order to make it work, open View Object and for those attributes defined as LOV components:


Open Control Hints section and change Auto Submit property to true:


Now LOV validation works for both - String type attributes:


And Number type:

14 comments:

ainara said...

Hi!
here i am again...

i'm fighting with a use case, similar to this but with one little diference.

I have a Query criteria and a lov inside of it, every thing ok.

but now I need the lov to be filtered so I follow the steps needed to pass the value to the bindvar defined in the viewCriteria of the Lov.
and doesn't work. the lov in the viewCriteria doesn't take the value.

Any idea?

Rowan.

ainara said...

Hi!
I need to ask you something...
why in page def in executables is defined a variables iterator??
Is it needed?

Rowan

Andrejus Baranovskis said...

Hi,

No, its not needed actually. Its just generated by JDeveloper automatically, but you can remove it, I think :)

Andrejus

renu said...

How to achieve this LOV validation in ADF 10g?

renu said...

How to achieve this LOV validation in ADF 10g ? LOV is implemented as af:selectInputText with LOV search page opening in separate dialog page.

Andrejus Baranovskis said...

Is supported only from 11g.

Andrejus

Sumit Yadav said...

Andrejus, even though the "Auto Submit" is set to true .
In my edit form I am giving emlployee_id : 123 which is not there in LOV and then hitting on Save, the data does not save as it is invalid, but i want to throw a exception to the user to give a valid one . any pointers ??

Andrejus Baranovskis said...

And what happens if you press Tab?

Andrejus

Sumit Yadav said...

If the user hit the tab it works fine and fires the validation as mentioned but what if the user hit directly "SAVE" button. Though the data is not updated but it also throws no exception and hence forth the user might think that everything might have gone good.
Please suggest.

Thanks
Sumit Yadav

Sumit Yadav said...

Just to add some more info, even if i tab out, the LOV pop out as it is a invalid data and i can select from the LOV, But if i do not select any value from the LOV, the focus again goes to the same place and i can hit save now,with out any exception.

On further debugging ,I put a logic on the commit method to check the values before commit,which throws error if the values written is not one among the LOV. ,I found that the bindings of the particular columns never got refreshed,it still holds the old data in the edit form.
and hence no error.
Not sure how to handle this .
Don't you think we should at least throw some kind of user exception .

Waiting for your expert advise .

Sumit Yadav said...

Got the solution.
The cause was because i was using a
showpop behavior component to invoke the popup, which was getting fired first and then the other validation were off there.

Lesson better to invoke Pop-up programatically and it worked kool.

Thanks
Sumit Yadav

Andrejus Baranovskis said...

Cool, you are finding solution faster, than I read comments :)

Fran├žois said...

Hello,

Do you know if it still works on 11.1.1.5, because I tested it and it doesn't work on my project...

Regards.

Fernando R. DalSotto said...

Very helpful post. I thought that this functionality wasn't available. Thanks for the post. Fernando