Wally,

The result of a cast is a null?

I wish that I could say that I encountered and solved that problem (but I
can't).

If you can send a little more code maybe I (or someone else here) will be
able to see where the current logic is failing.

If you might be up for it, following are notes on a different approach.

          hth,

          g

CF/Flex ValueObjects

Ben Forta had documented a "Phone Selector" application using value
objects.  Ben's app uses value objects and depends on "CFC to ActionScript
class mapping".  (Ben's app does not use the CF Wizard).  Following below
are excerpts from the article that you can find in its entirety here:
http://www.adobe.com/devnet/flex/articles/coldfusionflex_part3.html

Note:  "CFC to ActionScript class mapping" has very specific requirements
that are detailed in the excerpts below (on the CF side <cfproperty>; on the
Flex side: [RemoteClass(alias="CFIDE.samples.Phones.CF.Phone")], etc.)

btw ... If your app will be returning large datasets or has high performance
requirements, Ron Fuller posted a very important caution on this list last
week about how to pass value objects for best performance.  You can find
Ron's notes here (btw, thanks Ron):
http://www.archivesat.com/Flexcoders/thread2044582.htm

Ron's notes conclude:
Object creation in ColdFusion is very expensive. By passing structs and
letting the object creation happen client side, you can dramatically
increase performance especially with larger recordsets.

I have not yet had a chance to test and confirm what Ron highlights
(although I have seen the noticeably slow load times.)

EXCERPTS FROM FORTA PHONE SELECTOR ARTICLE
(Note:  See full
article<http://www.adobe.com/devnet/flex/articles/coldfusionflex_part3_03.html>for
missing pieces)
The ColdFusion code

The ColdFusion code consists of the following components and function:

  - *Phone.cfc:* Phone.cfc uses the <cfproperty> tag to list each
  property in this CFC. The properties, their names and types, and their exact
  order are extremely important. If these do not match the properties in the
  equivalent ActionScript file, mapping does not occur (and when the array
  phones arrives in Flex it is an array of generic objects instead of an array
  of Phone objects).
  - *Catalog.cfc:* To create the array of objects, Catalog.cfc uses the
  <cfinvoke> tag to create and populate a Phone.cfc (which is returned
  and appended to the array). The <cfinvoke> tag uses a fully qualified
  path to Phone.cfc, even though it is in the same folder. (In fact,
  component="Phone" would work). This, too, is to facilitate CFC to
  ActionScript class mapping. The fully qualified path is embedded in the
  array that is sent to the Flex application; it must match the path specified
  in the equivalent ActionScript class.
  - *getPhones():* The getPhones() function is the only function invoked
  from Flex. As a result, it must specify access="remote". Only CFC
  methods with this access level can be invoked through Flash Remoting.

The Flex code

The Flex code includes the following files:

  -

  *Phone.as:*
  - Phone.as defines a new class of type Phone. This is the class that
     maps to Phone.cfc on the server.
     - The actual mapping is performed with the following code:
     [RemoteClass(alias="CFIDE.samples.Phones.CF.Phone")]
     - This code matches the <cfinvoke> syntax in Catalog.cfc, which
     is how the object types are automatically matched to each other.
     - The properties are exactly the same as those in Phone.cfc;
     they match the names, types, and order, which is required for mapping to
     work.



On 11/17/06, Wally Randall <[EMAIL PROTECTED]> wrote:

Problem:
When I invoke the "get" function in the generated gateway object from
the CF Wizard I cannot cast the result to an instance in Flex.
In debug I can see that the event.result is returning data but when
this statement is invoked the result is a NULL thisPerson object in
Flex:

    thisPerson=event.result as Employee;

Any suggestions?

Reply via email to