Sunday, September 6, 2009

Programmatical Reset for Query Results

If you are using ADF Faces Rich Client af:query component in your application, probably you have noticed that if View Criteria is declared not to query automatically, query results are not cleared when Reset button is pressed. There is no bug in this, its how framework works by default, however what to do if customer wants to have it differently. Today I will describe how you can use executeEmptyRowSet() method in order to clear query results.

Its recommended for performance reasons to avoid query automatically on large data sets, naturally we are not performing query by default in today sample application:


In order to have more complex case, let's declare required query criteria parameters. Finally, our query and results table will look like this:


In my sample, if user will press Reset button in af:query, results table will be cleared:


However, by default only query criteria parameters are cleared, results table will remain populated. In order to clear results table, I have implemented query operation listener in Backing Bean, where I'm calling Application Module method and triggering partial refresh for results table:


Custom method implemented in Application Module - doQueryResultReset() invokes executeEmptyRowSet() in order to clear rows from iterator. Additionally in our case, because we have required query criteria parameters, we need to remove View Criteria before invoking executeEmptyRowSet() and reapply it again:


Download sample application - QueryReset.zip

10 comments:

Jan Vervecken said...

hi

See also some executeEmptyRowSet() related forum messages here
http://forums.oracle.com/forums/message.jspa?messageID=3788453#3788453

regards
Jan Vervecken

Andrejus Baranovskis said...

Thanks Jan,

Additionally can check here: http://andrejusb.blogspot.com/2009/08/oracle-adf-tuning-preventing-sql-query.html

Andrejus

Enig said...

hi

in my case, i have one required field (adf 11.1.1.0.1)

i have cleared the view criteria (same as your with "removeviewcriteria".

but i have required field error message.

(something can be forget or not say ?)

thanks

Enig said...

sorry, you can delete previous comment...

Anonymous said...

I want to capture query component mode(Basic | Advanced) in processQuery event listener method for QueryEvent as below:

public void processQuery(QueryEvent queryEvent) { // Add event code here... QueryDescriptor qdesc = queryEvent.getDescriptor(); String searchName = qdesc.getName(); String queryMode =?

I tried to get this value from getUIHints() map using UIHINT_MODE key. but getUIHints() returns empty map.

Andrejus Baranovskis said...

Hi,

You can probably use ViewCriteriaHints and set property programmatically. Using setProperty() method on ViewCriteria object.

Regards,
Andrejus

Anonymous said...

Thanks Andrejus Baranovskis,


i want to handle reset query in the LOV item.

regards
Amr Rashed

Chaitanya said...

Andrejus,

When user clicks on clear, I need to set an Criteria Item with specific Value Derived at runtime. Is it possible to do so?

Thanks,
Chaitanya Varma

Karen said...

Is there a way to auto change the search results when the user chooses a new saved search rather then requiring user to click on the Search Button? What would I use to capture the change event for the user saved search selection -- as you have done with the Reset? Ideally there would be a button beside the saved search so user does not have to OPEN the search each time they want to change a saved search to a different query result set.

asadrina said...

Thank you Andrejus Baranovskis

It was very usefull. But can u pls give me a blog in which the advance link in ADF Quick Query panel Such that when user clicks the link it must change into advance mode of af:Query