Friday, September 24, 2010

Making View Criteria Case Insensitive and MDS

In a previous post i had posted a workaround about making view criteria case insensitive:
http://adfbugs.blogspot.com/2010/07/making-view-criteria-case-insensitive.html
Yet this has 2 side effects.
  1. It makes values of criteria upercase.
  2. It brakes MDS save criteria functionality.


I found a simpler solution (workaround).
/**
* Set the view criteria rows to use case-insensitive querying and
* uppercase any of the non-null query-by-example criteria provided.
*/
private void doCaseInsensitiveOnStringsInViewCriteria() {
ViewCriteria[] vclist = getApplyViewCriterias(ViewCriteria.CRITERIA_MODE_QUERY);
if (vclist.length>0) {
for (ViewCriteria vc : vclist){
if (!vc.isUpperColumns())
vc.setUpperColumns(true);
}
}
}

@Override
protected void executeQueryForCollection(Object object, Object[] object2 int i) {
doCaseInsensitiveOnStringsInViewCriteria();
super.executeQueryForCollection(object, object2, i);
}
This code makes query criteria Case insensitive and also does not make values of criteria upercase.Yet it still brake MDS .
Sice we need this in LOV criteria that does not have Save search, we can prevent this code to execute in LOVs using :
if (this.getName().contains("LOCAL_VIEW_USAGE"))
doCaseInsensitiveOnStringsInViewCriteria();

Test case:
http://adfbugs.googlecode.com/files/MDSTestUpper.zip

No comments:

Post a Comment