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

Saturday, September 11, 2010

Validating Train Flow

A very nice option of Task Flows is the Train Task flow.

You can easily create a train task flow and add pages as Train stops and add in page train navigation and train buttons (Next/Previous) and create a wizard like navigation.

Yet many times you need to validate the input of a train stop before you go to the next one. When this validation is more complex than a required field you probably need to do it when the user tries to navigate to the next train stop.

I found a solution close to what I needed in Duncan Mills post: Executing Activities between Train Stops
http://groundside.com/blog/DuncanMills.php?blog=6&cat=18&page=1&disp=posts&paged=2
The strange thing is that you need to define an outcome on the target Train Stop activity.
Then you add a wildcard to go to a router to check your condition in order to decide to go to the target Train Stop or the source.




In my example the condition is if the Department has employees or not. If it has it go to employees page, if not it returns to department task flow.



The remaining issue is to show the appropriate message. In the example I have added it as a simple text that is visible when Department does not have Employees


Test Case:
http://adfbugs.googlecode.com/files/TestTrainValidation.zip