Wednesday, 13 April 2016

Have you ever tried resetting a filter applied on an ADF Table?

So, this is an issue(hack/fix for others probably) which I stumbled upon just today. I had a VOImpl method which was being invoked from my managed bean. So, what I was doing in that method was iterating through all the rows of a view object using a secondary RowSetIterator because I didn't wanted to mess up my current row (Yes getAllRowsInRange screws up your current row, better use a createRowSetIterator. Thats what all the other blogs on the internet would say). Oh yeah, and I also had this view object dragged and dropped as an ADF table on the UI, which also had a filter on one of the columns.
What was happening was that after the method was executed and the control was sent back to the JSFF, I would see the first row in the table as the selected row and it would become my current row of the view object.
What I observed was, that I had a method "resetTableFilter" being invoked from my managed bean method which was eventually calling the VOImpl method.

The source code for the method goes like this :

    public void resetTableFilter(ActionEvent actionEvent) {
        if (null != getHubTable()) {
            FilterableQueryDescriptor qd =
                (FilterableQueryDescriptor)getHubTable().getFilterModel();
            if (qd != null && qd.getFilterCriteria() != null) {
                qd.getFilterCriteria().clear();
                getHubTable().queueEvent(new QueryEvent(getHubTable(), qd));
            }
        }
    }
getHubTable is my getter in the managed bean for the binding of the ADF table on my UI.

When I commented the line where this method was called, I was able to retain the currency slot for my view object. So, which ultimately brought me to the conclusion that this method was resetting my current row to the first row in the table. It might be an issue which you might incur or it might also be a hack for people who want the first row to be selected on the UI. Anyways I am happy that I encountered something which I could share, happy coding!!!

No comments:

Post a Comment