When we Enable Sorting and Filtering and need to Default value in Filter for First or each time ,
create bean with table handle
create bean with table handle
public class MyBean {
public MyBean() {
}
public FilterableQueryDescriptor getCustomQueryDescriptor() {
String bindingEl = "#{bindings.MyVO1Query}";
FacesCtrlSearchBinding sbinding =
(FacesCtrlSearchBinding)JSFUtil.resolveExpression(bindingEl);
FilterableQueryDescriptor fqd =
(FilterableQueryDescriptor)sbinding.getQueryDescriptor();
if (fqd != null &&
fqd.getConjunctionCriterion() != null && isInitialQuery()) {
ConjunctionCriterion cc = fqd.getConjunctionCriterion();
List<Criterion> lc = cc.getCriterionList();
for (Criterion c : lc) {
if (c instanceof AttributeCriterion) {
AttributeCriterion ac = (AttributeCriterion)c;
if ((ac.getAttribute().getName().equalsIgnoreCase("Status")) &&
ac.getValues().isEmpty()) {
Map filterCriteria = fqd.getFilterCriteria();
if (filterCriteria == null) {
filterCriteria = new HashMap<String, Object>();
fqd.setFilterCriteria(filterCriteria);
}
filterCriteria.put("Status", "PENDING");
}
}
}
setInitialQuery(false);
RichTable tbl = getMyTable();
QueryEvent queryEvent = new QueryEvent(tbl, fqd);
sbinding.processQuery(queryEvent);
}
return fqd;
}
}
Change af:table property
filterModel="#{pageFlowScope.MyBean.customQueryDescriptor}"
References
http://lucbors.blogspot.com/2015/08/adf-1213-implementing-default-table.html
https://community.oracle.com/thread/2232873?tstart=0
http://www.awasthiashish.com/2013/11/apply-filter-on-aftable-column.html