Saturday, June 13, 2009

Working with View Criteria Items

I will describe how you can work with view criteria items in easy way. Often when you will use Oracle search component - af:query, you may face requirement to access entered criteria items and perform one or another action based on the result. I would like to recommend always base view criteria items on Bind Variables, this will greatly help you while working with query pages.

Download developed sample application - QueryCriteriaParams.zip. In this sample I'm accessing entered criteria item values and based on this show or hiding result components.

As I already have mentioned, I have declared view criteria based on Bind Variables:


In View layer I have overridden Query Listener (more: ADF Query Component and View Criteria Functionality with Custom Query Listener in 11g):


I'm accessing view criteria items directly in overridden Query Listener. I can do this by getting Bind Variable values from VO Variable Manager. Here is a power of defining View Criteria on Bind Variables, not just Literals. Sample code where I'm accessing criteria values and showing/hiding result components on the page:


On runtime, when page from my sample application is rendered, user will see just View Criteria available:


According to implemented logic, if user will enter First Name criteria and will do search, table component with results data will be present:


If user will enter both criteria parameters - Firs Name and Last Name, this means instead of table, form component will be rendered:

3 comments:

Michael Koniotakis said...

Realy Nice post,

Even though i wander why would someone want to do that...:)
People might have stange requirements....

An other way could be: instead of overriding query listener, to create a boolean method in backing bean that check the bind variables, and use that method on visible property of table and form.

ADF = Another development Feature
DEVELOPING WITH CHOISE

sai_explorer said...

Nice Post on accessing the view criteria items

Unknown said...

Hi andrejus,
I have tried this sample with a different aim. I got an error as follows,
"oracle.jbo.NotConnectedException: JBO-25200: Application module is not connected to a database."
My complete scenario is explained in the following OTN thread,
https://forums.oracle.com/message/11203519#11203519.
Could you please give me a helping hand resolving this.