- The Purpose of the Flex Data Management is to push data live and synchronize everything across the board with no HTTPservice requests or anything else that you have to do, everything happens in real time so you do not have to worry about a client not seeing up to date information. Ben Forta has a better explanation In this Tutorial I will show you how you can set it up and make everything work.
- Here is the example. http://sherifabdou.com/cfusion/DataPushSample/DataPushSample.swf. This is more complicated than what I am going over but the Source View is available so you can download it and try it out. To understand the power of Data Management, you need to open the example in two tabs. Now In one Tab Click on the DataGrid to edit the Database and in the other Tab click on the same item you clicked in tab 1 to also edit it. Now You have two windows open, change the Description in the first tab and in the second tab but have them both be different descriptions. Now go back to the first tab and click save. Now go to the Second tab, if you did it correctly you should get a screen similar to this.
- This Prevents the whole idea of racing where one information could be different from the other if two people are editing it at the same time
First thing you need is the ColdFusion 8 Extensions for Eclipse.
- Next go to where you installed Coldfusion 8 which in my case is C:\Coldfusion8\wwwroot\ and inside the wwwroot directory create a folder called cfusion. Open Flex Builder and make sure that your workspace is under C:\Coldfusion8\wwwroot\cfusion. Next thing is Create a project named DataPushSample and create a folder under src called exhd then sub folder cfc and action. It should look like this at the end
- Next Set up Eclipse to connect to the RDS Server by going to Window–>Show View–>Other–>ColdFusion–>RDS Dataview


- Now the RDS DataView should open, click on localhost to connect and type in your RDS Password when prompted. Next Thing you should do is click on cfartgallery then expand the Tables Folder and then Left Click on the APP.ART table then Select ColdFusion Wizard then Click on Create CFC

- Now You will then get a popup, make sure to follow and type in the exact same thing as in the picture below

- So Now comes the Hard part, for some reason the Wizard screws up everything so you have to manually do everything. Now for the CFC Package Name and why it is cfusion.DataPushSample…, the Reason for this is you need to have the package name from the wwwroot and start to drill down. For Example, if you created under wwwroot a Folder called flex and a subfolder called coldfusion and in that ColdFusion folder is your workspace then the CFC Package name would have to be flex.coldfusion.DataPushSample.src.exhd.cfc. You must keep drilling down until you reach the cfc folder.
- For the Actionscript part ignore the src folder and just go on as if making a regular actionscript file so if the Actionscript file was stored in DataPushSample/src/exhd/action. Package level name would only be exhd.action
- Click Finish and Everything Should have been created and read to go
- From Here on I will assume that you installed Coldfusion in C:\coldfusion8
- Go to C:\coldfusion8\wwwroot\WEB-INF\flex\
- Open up the Services-config.xml File , Look for this channel
<!– ColdFusion specific RTMP channel –>
<!–
<channel-definition id=”cf-rtmp” class=”mx.messaging.channels.RTMPChannel”>
<endpoint uri=”rtmp://{server.name}:2048″ class=”flex.messaging.endpoints.RTMPEndpoint”/>
<properties>
<idle-timeout-minutes>20</idle-timeout-minutes>
<serialization>
<instantiate-types>false</instantiate-types>
</serialization>
</properties>
</channel-definition>
–>
- Uncomment that whole block so in the end it looks like this

- Open data-management-config.xml
- Add the following destination below the adapters tag
<!-- ======================================== --> <!-- ColdFusion - DataManagement sample application --> <!-- ======================================== --> <!-- Use the ColdFusion adapter for any CF specific destinations --> <!-- Use the ColdFusion configured channels which have the instantiate-types flag set to false. --> <!-- The component name or path on the CF server --> cfusion.DataPushSample.src.exhd.cfc.ARTAssembler <!-- Either "application" or "request" --> application <!-- Should we look for "getFoo" or "setFoo" when translating an ActionScript object to a CFC? If not found, the value is set in the "this" scope. If your CFCs don't have getters and setters, (they use the this scope) set this to false for better performance. Optional, Default is true - look for accessor functions. --> true <!-- Should we create CFML Structures instead of value objects when translating an ActionScript object with a remote alias? Optional, Default is false (use CFCs) --> false <!-- The hostname or IP address of the CF host. If Data Services is installed as part of CF, you omit this. If Data Services runs outside of CF, you must define this. <hostname>localhost</hostname> --> <!-- This is the ID of the ColdFusion Data Management service as configured in the ColdFusion Administrator. Only needed if you have more than one instance of CF on a machine and Data Services is not installed as part of CF. <identity>default</identity> --> <!-- Credentials to pass to the assembler CFC for all clients Generally better to use setRemoteCredentials() API on client <remote-username></remote-username> <remote-password></remote-password> --> <!-- Define the resolution rules and access level of the cfc being invoked --> <!-- allow "public" (and remote) or just "remote" methods to be invoked --> remote <!-- Optional controls for forcing property names to lowercase when converting to ActionScript --> <!-- cfc property names --> false <!-- Query column names --> false <!-- struct keys --> false <!-- Optional, If the Assembler fill routine returns a query, you must define an Actionscript type for the rows. <query-row-type>samples.contact.Contact</query-row-type> --> <!-- Add network elements here --> <!-- The method declarations are ignored for CFC Assemblers, with the exception of the fill-method settings. No parameters are defined here, unlike Java. Any arguments provided via the AS call are passed along to the CFC, just use optional arguments when defining the CFC. --> <!-- Does the assembler have a "fill-contains" method? This method is used to determine whether to refresh the fill. If the specified method returns true the fill is re-executed after a create or update. Auto-refresh determines if the fill is always refreshed if not specified. May only be used when auto-refresh is true. Optional. Default is false. --> false <!-- Determines whether to refresh the fill on updates or creates. Optional. Default value is true. --> true <!-- Determines whether order is important for this filled collection. Allows for performance optimization when order is not important. Optional. Default value is true. --> true
- Here is what it should look like data-management-config.xml
- Now there are 4 import things that must be included with every destination so it works
- <destination id=”cfartgalleryDS”> You need to have a destination id so you can connect
- <component>cfusion.DataPushSample.src.exhd.cfc.ARTAssembler</component>
You must specify where the Assembler component is which as stated before you have to drill down from the wwwroot folder. - <scope>application</scope> needs to be application
- <identity property=”ARTID”/> this needs to be the Primary key in your Table.
- Next thing you must do is either restart your computer or restart the coldfusion8 server for these setting to take effect, otherwise it will never work.
- If everything up until now worked then you should be able to test out your Application.
- In the DataPushSample.mxml add the following
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initApp()" viewSourceURL="srcview/index.html"> <mx:Script> <![CDATA[ import exhd.action.ART; import mx.collections.ArrayCollection; [Bindable] private var myGridData:ArrayCollection = new ArrayCollection(); /** * @private * This Is a Dummy Variaiable, You MUST Include it otherwise Flex * *Will not Compile the Class and You will get an Error of * [RPC Fault faultString="Error during update: The OLDBEAN argument passed to the update * function is not of type foo." faultCode="null" faultDetail="null"] */ private var dummyVariableToCompile:ART = new ART(); private function initApp():void { myDataService.fill(myGridData); } ]]> </mx:Script> <mx:DataService destination="cfartgallery" autoCommit="true" id="myDataService" /> <mx:Text text="If You Are Not Convinced that it works, You can always refresh the page to see that it has been commited to the DataBase"/> <mx:HBox> <mx:Panel title="DataBase That Uses DataService to Update in RealTime" > <mx:DataGrid dataProvider="{myGridData}" width="500" height="600" editable="true"> <mx:columns> <mx:DataGridColumn dataField="ARTID" editable="false"/> <mx:DataGridColumn dataField="ARTISTID" editable="false"/> <mx:DataGridColumn dataField="ARTNAME" editable="true"/> <mx:DataGridColumn dataField="DESCRIPTION" editable="true"/> <mx:DataGridColumn dataField="PRICE" editable="true"/> <mx:DataGridColumn dataField="LARGEIMAGE" editable="true"/> <mx:DataGridColumn dataField="MEDIAID" editable="true"/> </mx:columns> </mx:DataGrid> </mx:Panel> <mx:Panel title="Dummy Sync to show it works" > <mx:DataGrid dataProvider="{myGridData}" width="500" height="600"/> </mx:Panel> </mx:HBox> </mx:Application>

Most Common Errors and Their Solution
- [RPC Fault faultString="Error invoking fill-method 'fill' for destination artgalleryDS: Unable to invoke CFC - Error invoking CFC fill operation:Could not find the ColdFusion Component or Interface cfusion.DataPushSample.src.cfc.ARTAssembler." faultCode="Server.Processing" faultDetail="null"]
- This Either means You need to do the ColdFusion Mapping, or you gave the wrong <component></component> path wrong in the data-management-config.xml file. Double check this
-
[RPC Fault faultString="Error during update: The OLDBEAN argument passed to the update function is not of type foo." faultCode="null" faultDetail="null"] - This would mean that you did not Include the Art.as file in flex, this needs to be included somehow otherwise Flex will not compile it. Easiest solution is to drop this in the main mxml file.
private var dummyVariableToCompile:ART= new ART();













(No Ratings Yet)
Chatter Wall RSS Feed
23/07/2008 at 10:00 am Permalink
Hi Sherif
I Keep getting this error.
Configuration error encountered on line 1, column 8: ‘The processing instruction target matching “[xX][mM][lL]” is not allowed.’ DataPushSample Unknown
No Idea What its supposed to mean.
Rob
23/07/2008 at 2:26 pm Permalink
There is some white space before the document declaration in your CFC File make sure that there is nothing before tag or whatever is first, here is a link for more http://www.bennadel.com/blog/58-The-Processing-Instruction-Target-Matching-xX-mM-lL-is-Not-Allowed.htm