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