af:table provides
column filtering feature when filtering is enabled in the table. Sometimes, we want to override the filtering feature
with our custom business logic.
Examples of some of the business scenarios are explained
below.
Usecase 1:
We should not allow the user to enter anything in the field
provided for filter, instead we want him to choose from a list of values
already provided and perform filter on only them.
Usecase 2:
We do not want to allow characters and force him to enter
only numbers in the filter field.
Usecase 3: (Most
people need)
When a default filter is invoked, ADF fetches the data from
the database. If the table is an editable table and if there are any
modifications performed, all the changes will be lost because the data is fetched
from the DB. Most of the times, we do not want to lose the data and want to
perform a filter on the existing view state.
This blog explains these features.
- Create an EmployeeEO and EmployeeVO. (using the default hr schema in this example)
- Create a jspx page and drop the EmployeeVO as an af:table with filtering enabled.
4. Now, drop an af:inputText in the EmployeeId
filter facet.
5. Bind the af:inputtext to the bean.
6. If you want to override the filter feature, we need to override the QueryListener on af:table.
7. In the bean, write the below code.
8. This query mode will help in performing In-memory query without a need of a DB
hit and hence we don’t lose any modifications done in the UI.
9. As below, I have modified the Employee name from
Steven to Stevenaaa.
. 10. And performed a search for EmpId 130.
11. Again, ran a query to fetch EmpId 100. If you
see the modification still exists and the data is now not fetched from DB.
Instead it is fetched from the cache.
In the similar way, If we want to have an LOV in the filter facet, have an af:selectOneChoice. If we want to restrict the user input, we can restrict it in bean or in the UI by using regular expression.
Hope this helps :)
Sorry, the "empIdFilter" input box in my case, it's value is null on the first time. I traced the java code. I find that its ValueChangeListener does not triggered on the first time (even cursor is left). So It does nothing on the first search. Please help.
ReplyDeleteDo u have autosubmit=true set on the input box?
ReplyDelete