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 -


Jan Vervecken said...


See also some executeEmptyRowSet() related forum messages here

Jan Vervecken

Andrej Baranovskij said...

Thanks Jan,

Additionally can check here:


Unknown said...


in my case, i have one required field (adf

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 ?)


Unknown 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.

Andrej Baranovskij said...


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


Anonymous said...

Thanks Andrejus Baranovskis,

i want to handle reset query in the LOV item.

Amr Rashed

Chaitanya said...


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

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.

Unknown 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

Anonymous said...

Hi Andrejus,
I am using <f:facet name = "filer"
and I have a dropdown facet. When I clear my filter the table search clears off however the box that contains my dropdown still has the selected option for filtering. Any ideas on how to reset it back to blank?

Mark said...

Hi Andrejus,
Thanks for your many excellend ADF articles.
I have implemented a hierarchy viewer with search functionality (as per 26.7.3 in ) which works well and shows the hierarchy initially at 3 levels (displayLevelsChildren="3"). If the user searches and selects a child node the hierarchy is re-drawn correctly with the selected node as the root node and child nodes also displayed.
I want the user to be able to reset the query so have added a button which calls a method (executeRootQuery) to try to reset the search and allow the user to easily go back to the original hierarchy (showing the root node and all children):

public String executeRootQuery() {
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
AttributeBinding searchStringAttr = (AttributeBinding)bindings.getControlBinding("pSearchString");

AttributeBinding employeeIdAttr = (AttributeBinding)bindings.getControlBinding("pEmployeeId");

//ExecuteWithParams refers to the Search in the bindings
//ExecuteWithParams1 refers to the Hierarchy in the bindings
return null;

BUT - When this hierarchy is redrawn it shows only the ROOT node and the user needs to manually expand the levels beneath it?
Any ideas on how to reset the hierarchy to display the root node and all the child nodes as it did before the initial searchy was executed??
Searching for the root node and selecting this using the Hierarchy Search function works fine but this would require the user to search for the root node and then double click on it - But I would like to have a single button to do this automatically...

Andrej Baranovskij said...

I will need to research this.


HDS said...

Hi Andrejus,
Thank you for the post again. It has be informational as always. I was wondering if there is a way use Java/ADF API to invoke the processQuery instead of using EL expression "#{bindings.QueryByVacationRangeQuery.processQuery}"


Andrej Baranovskij said...

To call from JSF UI level you need to use EL.