Thursday, April 20, 2006

Next time, I'll have to rtfm.

A few weeks ago, I joined a discussion about flex remote objects in CF. The question of the day was: "How do you set separate result/fault handlers for each method in a cfc?"

You've probably seen this construct in one of the examples already. It looks something like this:

<mx:remoteobject id="a_named_reference_to_use_in_mxml"

You would normally set one of these up for each cfc you intend access from within Flex.

Some of the comments mentioned that people are either creating switch statements and picking apart some header information returned in the result to get the name of the method call. Others were creating a separate remote object for each method (I'm not sure that this would even work).

Had I bothered to scour the docs a little better, I would have found the real way to do this. the mx:RemoteObject tag can take a child tag. It might wind up looking something like this:

<mx:remoteobject id="a_named_reference_to_use_in_mxml" destination="CustomID">
<mx:method name="method1" result="method1Result">
<mx:method name="method2" result="method2Result" fault="method2Fault">

Problem solved. Thanks to Simeon Bateman for showing this on his terriffic presentation at BACFUG!

No comments:

Post a Comment