Skip to main content

Programmatically resetting the <af:query> and search result table

If you want to programmatically reset QueryModel of <af:query> component, you can use the following code snippet in your managed bean.

     RichQuery queryComp = getRichQuery();  
     QueryModel queryModel = queryComp.getModel();  
     QueryDescriptor queryDescriptor = queryComp.getValue();  

Along with the above requirement, If you need to reset the contents of result table as well, then call executeEmptyRowSet() on the ViewObject which is wired to the result table.

I'm attaching simple application illustrating the above discussed points. You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS3 + HR Schema]

A glance at the implementation

This example displays a popup with a search panel and result table. The custom popupFetchListener method added for the af:popup component resets the search panel and result table contents before displaying the popup.

Learn More ...
There are a lot more points like this. If  you are curious to learn the internals of the ADF Business Components and ADF Binding Layer,  the following book is for you - Oracle ADF Real World Developer’s Guide.
More details about this book can be found in this post-


Anonymous said…
As always thanks for share with us your examples !!
Prateek shaw said…
what if i used execute with param and how to reset the table
Jobinesh said…
Well, if the question is how to clear the table, then you can use VO::executeEmptyRowSet(). Does not matter how you did execute the method from UI.
Unknown said…
where to I apply VO::executeEmptyRowSet() because of I used execute with param

Arvind said…

I have a query panel, with two attributes (First Name & Last Name). I want to set certain values for these bind variables in the query panel, and when the popup comes up, I want the query panel to show the right values with the table also showing the right results.

I set the values in the view criteria, and the table is showing the right results, but the query panel shows the value from the previous invocation.

First Invocation (Invoked for John Doe)
First Name - Empty
Last Name - Empty
Table Shows results for First Name-John and Last Name - Doe

Second Invocation (Invoked for Steve Smith)
First Name - John
Last Name - Doe
Table Shows results for First Name-Steve and Last Name - Smith

Any pointers?

Jobinesh said…
Try setting intialQueryOverridden=true for search binding and execute VC from the popupFetchListener
Danesh said…
Is there any way to reset the filtered results on the table when click on the reset button.

After reset results table should display all available table not filtered results

Is this possible??
renganathan said…
Hi Jobinesh,

I would like to reset the viewcriteria with view results, but by default all the records should display once reset. Please advice. if i use execute query to view object, it will fetch record from db, so all my updated changes in the table will get reverted. Please sugggest some solution.
I have used QuickQuery with table in the popup.I have two attributes in the search,once i done search on second attribute and click the cancel button.then after i opened the popup,still it is pointing to second attribute.please answer this issue
Anonymous said…
Hi ,

I have table with in the fragment . I dragged and dropeed as a region into jspx page . When i try to fetch the UI component " qryId1 " from the jspx page as pt1:region:0:qryId1 (findRichQueryInView(" pt1:region:0:qryId1"); ). Its throwing me null error .

Can you suggest how to get ride of this issue.
Anonymous said…
I mean with in the region
Anonymous said…
sorry for some reason af query is not getting displayed with in the comment
aikidoka25 said…

I need to clear the query, however I have the VO pre-executed in the AM.
Do you have any hints for me on how to achieve this?

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!