Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

TypeError: Error #1034: Type Coercion failed:

Avatar

Level 2
I am trying to get my head around FDS and Coldfusion by
working with the CRM sample app. For the most part I have followed
Tom Jordahl's "Using ColdFusion with Flex – Part 2: Creating
and running a CRM application" but with a few minor changes.



I moved the 'crm' folder out of the 'samples' folder and
renamed the subfolder the .as files are in from 'sample.crm' to
'com.crm' (I changed all .mxml, .as and .cfc references
appropriately)



When I call companyapp.mxml from a browser the datagrid is
display and populated. The problem arises when I click on a record
in the displayed data. I expected the row's data to be display in
the form fields. Instead I get a popup with:



TypeError: Error #1034: Type Coercion failed: cannot convert
mx.data::ManagedObjectProxy@3331e09 to com.crm.Company.

at companyapp/::companyChange()

at companyapp/__dgCompany_change()

at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at
mx.controls.listClasses::ListBase/mx.controls.listClasses:ListBase::mouseUpHandler()

at
mx.controls::DataGrid/mx.controls:DataGrid::mouseUpHandler()



Can someone tell me what I am doing wrong?



thx



pwp
10 Replies

Avatar

Level 3
Hi,



I haven't tried the crm sample in cf. The error is trying
cast a untyped object into to com.crm.Company. Can you verify your
Company.as' meta data?

Did you make change of the following?

from

[RemoteClass(alias="samples.crm.Company")]

to

[RemoteClass(alias="com.crm.Company")]



Hope it help!



Thanks!

William Chan

Avatar

Level 2
Thank you for your response, William.



The meta data is correct in both .as files



I found this topic:.
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=585&threadid=1169105&CFID=1242873...



It started out sounding like my problem (#1034). But then it
turned into a remote server issue. Maybe it can shed some light on
my problem.



What object is being cast in to a 'com.crm.Company'? Is it a
returned company data row from the grid?



pwp

Avatar

Level 3
i am going to follow the instruction to install CF today to
try it out. However, you can debug it by change the logging lvl to
debug in services-config.xml. Check the reponse is a typed object
or not.

As you know the exception is coming from

company =
Company(companies.getItemAt(dgCompany.selectedIndex));

if some configurations go wrong, server returns a object
proxy. In this case,

the workaround is (don't cast it to typed object)

company = companies.getItemAt(dgCompany.selectedIndex);



Thanks!



William Chan

Avatar

Level 2
William,



I see the <logging></logging> tags in
service-config.xml. How do I set the logging to debug?.



pwp

Avatar

Level 2
I figured how to set log level to debug...



Interesting thing is I don't get any log output when I click
the data row. I only get the error popup.



Comments?



pwp

Avatar

Level 3
When you click on the item on datagrid, there is no debug
information on the server's log, since the data is already loaded.
I am sorry about the confusion. What I meant was the log from the
server when the data was loaded. You should be able to see the
serialized objects' information

Avatar

Level 3
I downloaded the cfcrm app. I found the cfc have
<cfcomponent output="false" alias="samples.crm.Company"> Did
you also fix this when you changed the package?



William Chan

Avatar

Level 2
Instructions for configuring server-side service logging are
available in the Flex 2 Developer's Guide. Here's the link to the
relevant section -




http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Pa...

Avatar

Level 2
Yes. I changed all cfc aliases too.

Avatar

Level 3
hi,



Have you found the problem yet? Did you try the debug feature
in FDS to find out the serialized object type? It should be
somewhere in the codes still using sample.crm.Company, since it
worked before you changed the package. If you need, you can zip it
up and send to me. I can take a look



William Chan