English Spanish
Straker » Blog » 2008 » Lowercase Returned Results in a Delegate

Lowercase Returned Results in a Delegate

In ZoomFlex, the various Delegate classes make calls to server-side methods. Often such calls may involve returning a query from the remote method. There are times (depending on the ColdFusion server configuration/version), when the the column names in returned query contain upper-cased column names. For example, if you make a call to server-side method to return two fields, say obj_uuid and label, the returned query might contain these files in upper case like, OBJ_UUID and LABEL.

This is not much of a problem when a ColdFusion script calls the the method on the server-side as ColdFusion disregards cases when executing server-side scripts. However, it becames a major issue in Flex where case-sensitivity matters.

Here is a utility function that can convert all upper case column names in a returned query to lower case.

private function toLowercase(ac:ArrayCollection):ArrayCollection {

    var acLowerCase:ArrayCollection = new ArrayCollection();

    for(var i:int = 0; i< ac.length ;i++){

        var tmp:Object = new Object;

        for (var it:* in ac[i]){
           tmp[it.toLowerCase()] = ac[i][it];
        }

        acLowerCase.addItem(tmp);

    }

    return acLowerCase;

}

 

Once this is added to the Delegate class, you can call it from a result handler method as demonstrated in the following code 

private function onResults_yourMethod(event:*):void{

   var acReturn:ArrayCollection = toLowercase(event.result);

    notifyCaller(event);

}

 

Advanced tip: When you use the auto generated methods like getVOs or getFilteredVOs, the returned results are automatically converted to lowercase by the onResults_convert2VOs() method that handles the results of these calls. Have a look at the the generated code for this method. It not only shows how to convert returned column names to lower case, but also how to type each row in the returned results to a ValueObject.


Comments

There are no comments for this page as yet.

Add a comment