I thought I would loop back to this thread and post one solution for
my own problem (populating a Flex dataProvider from an OpenBD query
object delivered via remote cfcomponent).

Here's my first run at a function which accepts an OpenBD query
(fetched using mx.rpc.soap.WebService) and converts it to an
ArrayCollection that pleases the Flex 3 dataProvider.

(To actually use any of this, you'll need to import
mx.collections.ArrayCollection, mx.utils.ObjectProxy,
mx.rpc.soap.WebService; perhaps some others I might have missed)

--- start sample 1
public function openBDQuery2FlexProvider
(openBDQry:ObjectProxy):ArrayCollection
{
        var loopObj:Object = new Object;
        var ACresult:ArrayCollection = new ArrayCollection;
        for (var x:int = 0; x < openBDQry['data'].length; x++)
        {
                loopObj = new Object;
                for (var y:int = 0; y < openBDQry['columnList'].length; y++)
                {
                        loopObj[openBDQry['columnList'][y]] = 
openBDQry['data'][x][y];
                }
                ACresult.addItem(loopObj);
        }
        return ACresult
}
--- end sample 1

So, if you already have some Flex code that calls an OpenBD web
service, something like this:

--- start sample 2
private var myWS:WebService;

public function useMyWebService():void
{
        // set cursor waiting here
        myWS = new WebService();
        myWS.wsdl = "http://www.mydomain.com/mycomponentfile.cfc?wsdl";;
        myWS.useProxy = false;
        myWS.myMethodName.addEventListener("result",myHandlerFunction);
        myWS.addEventListener("fault", myFaultHandler); // function not shown
in this example
        myWS.loadWSDL();
        myWS.myMethodName(argument1,argument2);
}
--- end sample 2

Then your event handler would look like this:

--- start sample 3
public function myHandlerFunction(event:ResultEvent):void
{
        // set a breakpoint here so you can discover the path_to_query_object
in your version
        myFlexComponent.dataProvider=openBDQuery2FlexProvider
(event.result.path_to_query_object_goes_here);
        // set cursor back to normal here
}
--- end sample 3

I'm betting that someone has a more efficient way to write their own
openBDQuery2FlexProvider() function, and look forward to any pointers.

Alan K Holden
(877) 254-7225

--~--~---------~--~----~------------~-------~--~----~
Open BlueDragon Public Mailing List
 http://groups.google.com/group/openbd?hl=en
 official site @ http://www.openbluedragon.org/

!! save a network - trim replies before posting !!
-~----------~----~----~----~------~----~------~--~---

Reply via email to