| By Nahuel Foronda, Laura Arguello | Article Rating: |
|
| July 19, 2007 01:30 PM EDT | Reads: |
82,328 |
Receiving Responses from the Server
If you recall, when you created the RemoteObject, each of the methods of the RemoteObject tag specified a function to be called when the response came back from the server:
<mx:method name="getAll" result="tasksReceived(event)" />
<mx:method name="save" result="taskSaved(event)" />
You already implemented the tasksReceived() function but left taskSaved() incomplete. This function will be called either because a new task was added or because a task was set as done. In each case, you should do something different. You could also implement two different methods in the service if you'd like to separate them.
If a new task was created, you want to add it to the main list of tasks, that is, to the "tasks" ArrayCollection that feeds the Repeater. If the task was updated (set as done), you want to remove it from the list.
private function taskSaved(event:ResultEvent):void {
var taskItem:Task = event.result as Task;
var i:Number = -1;
if (taskItem.done){//we must remove it
//find task in list
for each (var thisTask:Task in tasks){
i++;
if (thisTask.id == taskItem.id){
//remove this item
tasks.removeItemAt(i);
break;
}
}
}
else {
tasks.addItem(taskItem);
}
}
Making Changes to the Generated ColdFusion Components
To make everything work, you'll have to make a couple of changes in the generated ColdFusion components. First you'll need to make the Task component generate a unique key before storing the data in the database:
<cfset var local0 = createUUID() />
<cfset setId(local0) />
That should be added to the "create" method.
Then your TaskGateway component should return the task it got in the "save" method:
<cffunction name="save" output="false" access="remote">
<cfargument name="obj" required="true" />
<cfset obj.save() />
<cfreturn obj />
</cffunction>
While you're at it, you may also want to change the getAll method so that it returns only the undone items, or you may want to delete the task when it's set as done.
Final Touches
As a final touch, you can add styling information to the application and to each individual control. An application-wide style file can be added by using the
As you can see, integrating Flex with ColdFusion is very simple and the CFC wizards greatly simplify the task. In addition, with the new Flex/ColdFusion connectivity features, you can send object instances from Flex to ColdFusion and from ColdFusion to Flex as if they were instantiated locally like you did with the Task.cfc-Task.as class mapping.
We hope this sample application gets you started using Flex and ColdFusion together to offer your users a nicer experience. We've only scratched the surface with this article; you can do much more with Flex. As your next steps, you can look at the sample code, read the tutorials at Adobe, and get your feet wet with an application of your own.
Published July 19, 2007 Reads 82,328
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Nahuel Foronda
Nahuel Foronda is one of the founders of Blue Instant (http://www.blueinstant.com), a web development firm specializing in Rich Internet Applications where he has been creating award-winning applications and offering training for the last five years. He also maintains a blog, called AS Fusion (http://www.asfusion.com), where he writes about Flash, ColdFusion and other web technologies.
More Stories By Laura Arguello
Laura Arguello is one of the founders of Blue Instant (http://www.blueinstant.com), a web development firm specializing in Rich Internet Applications where she has been creating award-winning applications and offering training for the last five years. She also maintains a blog, called AS Fusion (http://www.asfusion.com), where she writes about Flash, ColdFusion and other web technologies.
![]() |
??? 10/30/07 01:47:34 AM EDT | |||
Ipod MP4 ???? |
||||
![]() |
donna 10/12/07 01:28:46 PM EDT | |||
Unable to download the source code. When I got to page http://www.asfusion.com/projects/my-to-do-list/ I received a Coldfusion error: A License exception has occurred. There are so many issues encountered with the tutorial apps out there, that dont work when people follow the isntructions exactly. We need apps that work when followed, and we need downloaded source code that will actually be there. |
||||
![]() |
Lara 07/30/07 11:59:27 AM EDT | |||
I am familiar with ColdFusion but completly new to Flex. I can't get the code to work and I am very frustrated. This isn't a good first application example if we can't work the code. Does anyone have the working source files? If so, please post a link to the corrected files. Thanks! |
||||
![]() |
Jason 06/26/07 02:20:44 PM EDT | |||
I love all the article put out by sys-con and found that they are top quality, that is until this one. I have been struggling with learning Flex and found this article and initally was excited because it looked like the article that was going to clear things up. Until I started in and realized that this article is full of mistakes. Flex is VERY case sensitive where as ColdFusion is not. Since this article is target at ColdFusion developers you need to make sure that the code is correct expecially in the area of case sensitivity because we ususally don't think in that manner (it is "faultString" not "faultstring"). Also you need to make sure that you are using the same name for functions. You have us call the addItem() function through a click event but then on the next page we create the saveItem() function to handle that click event. This won't work! Then we need to make changes to the generated CFCs. You show us the two lines of code that we need to add and simply state that they "should be added to the 'create' method." Ok, but where in the create method. I moved them all over and I continually get errors. I have yet to find a competent article for the Flex "newbie" that achieves its goal of showing how to do basic updates and adds with Flex and CF. I thought that this was going to be the one. Guess I was wrong! |
||||
![]() |
KTK 06/07/07 03:53:09 PM EDT | |||
I'm glad it's not just me! I've had to put this aside for a couple weeks to work on a CF project. Hopefully I can get back to it later this month. If you figure something out, let me know and if I figure it out, I'll let you know. In the meantime, maybe a savior will come along for both of us! |
||||
![]() |
Scott 06/07/07 01:30:06 PM EDT | |||
KTK - I have the same problem and I followed all of the instructions exactly. Uf! |
||||
![]() |
KTK 06/04/07 01:28:59 PM EDT | |||
I'm getting an error that says "A file found in a source-path must have the same package structure '', as the definition's package, 'Task'. I've been beating my head against it for hours and can't figure out why I'm getting the error. Any ideas? |
||||
![]() |
jex 11/04/06 11:26:10 AM EST | |||
OK - I'm a bit new to both Flex and CF, but have been implementing the tutorial fine up until: "Going back to the main application file (mytodolist.mxml), switch to the design view and drag a new panel and inside drag your EditForm component." When I drag the EditForm component onto the panel, nothing happens. Would it be possible to explain exactly what has to be done here? Many thanks. |
||||
![]() |
jex 11/04/06 11:24:25 AM EST | |||
Problem solved - I was trying to drag the EditForm.mxml - but it's the EditForm component(as it says in the tutorial)which needs to be dragged - this is found in the custom component folder. |
||||
![]() |
jex 11/04/06 10:19:33 AM EST | |||
OK - I'm a bit new to both Flex and CF, but have been implementing the tutorial fine up until: "Going back to the main application file (mytodolist.mxml), switch to the design view and drag a new panel and inside drag your EditForm component." When I drag the EditForm component onto the panel, nothing happens. Would it be possible to explain exactly what has to be done here? Many thanks. |
||||
![]() |
Francois-Yanick Bourassa 08/09/06 04:21:30 PM EDT | |||
I found myself a bit confused to follow this article as it is a bit out of the real target - which is bringing new people to use Flex and ColdFusion. As a ColdFusion programmer, I found very interesting to try this example with Flex. But after couple paragraphs, started to be confused on which file I was suppose to put the code as Flex is a real new thing for me - I'm sure it will be the same for few of us - if it is not more! We use to read article where editor just put rectangle on source code by page - but this article seems to have a different goal! I will figure out what was wrong in the code because I think I can but what about newbies!!! This was my personal feedback! |
||||
![]() |
AJAXWorld News Desk 08/09/06 08:35:47 AM EDT | |||
Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success. |
||||
![]() |
cfdj news desk 08/08/06 08:29:03 PM EDT | |||
Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success. |
||||
![]() |
CFDJ News Desk 08/08/06 07:25:22 PM EDT | |||
Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success. |
||||
![]() |
AJAXWorld News Desk 08/08/06 07:11:51 PM EDT | |||
Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success. |
||||
![]() |
AJAXWorld News Desk 08/07/06 03:11:03 PM EDT | |||
Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success. |
||||
![]() |
SYS-CON Australia News Desk 08/07/06 09:34:46 AM EDT | |||
Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success. |
||||
- Microsoft’s First Step Toward Cloud Computing
- Adobe Flex Developer Earns $100K in New York City
- Jill T. Singer of CIA to Present at Cloud Computing Expo on November 2
- Visual Studio 2010 Is Cloud Friendly
- SplendidCRM for Microsoft Windows Azure
- Microsoft Falls Off Cliff, Keeps on Ticking
- Microsoft to Data-Mine Facebook & Twitter
- Amazon RDS vs. SQL Azure
- Azure Gets its First Commercial ERP App
- Qt DevDays 2009 - Munich
- Installing Geneva Beta 2 on Windows 7
- Binary Serialization and Azure Web Applications
- Yahoo! to Present at 4th International Cloud Computing Expo
- Microsoft’s First Step Toward Cloud Computing
- Social Media on Ulitzer - Strategy Nets New AUM for RIA
- EC Wrong, Wrong, Wrong – and Sloppy to Boot: Intel
- Adobe Flex Developer Earns $100K in New York City
- This Bing Thing Is Working
- Jill T. Singer of CIA to Present at Cloud Computing Expo on November 2
- Visual Studio 2010 Is Cloud Friendly
- SplendidCRM for Microsoft Windows Azure
- Azure on Ulitzer - Microsoft’s Cloud Builder Floats to Cisco: Report
- Governmental Cloud Interoperability on The Microsoft Cloud
- Microsoft Falls Off Cliff, Keeps on Ticking
- Where Are RIA Technologies Headed in 2008?
- The Top 250 Players in the Cloud Computing Ecosystem
- Accessing the ASP.NET Authentication, Profile and Role Service in Silverlight
- Silverlight 2 - Adobe Flex Killer Is on Its Way!
- Building Great AJAX Applications Using ASP.NET
- Spice Up User Experience with Silverlight
- Is the Silverlight Adoption Rate Artificially Inflated?
- Kaazing Announces Support for Silverlight
- Will Google's Android Sink or Swim?
- VS 2008 Builds AJAX-based Web Apps
- Rich Content Rotator for ASP.NET
- Getting Started with Silverlight: Zero to Hero





































