YOUR FEEDBACK
SOA Viewpoint: Have We Got It All Backwards with Software Assembly?
Bill Swanson wrote: Yes, Ford paid a "little bit better", just twice as mu...
SOA World Conference
Virtualization Conference
$50 Savings Expire May 23, 2008... – Register Today!


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP COLDFUSION LINKS


Your First Adobe Flex Application with a ColdFusion Backend
The wow factor plus usability

Digg This!

Page 3 of 4   « previous page   next page »

Adding a Form To Insert Items
Just like you created the TaskItem component, create another one called "EditForm.mxml" that extends the Canvas. In the Design view of this newly created component, add a Textarea with the id "descriptionArea," a ComboBox with the id "priorityList" and a Button. In the Source view, add the priority items to the ComboBox:

<mx:ComboBox id="priorityList">
    <mx:dataProvider>
<mx:ArrayCollection>
<mx:source>
<mx:Object label="High" data="1"/>
<mx:Object label="Medium" data="2"/>
<mx:Object label="Low" data="3"/>
</mx:source>
</mx:ArrayCollection>
</mx:dataProvider>
</mx:ComboBox>

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. At this point, your main application should have a list of tasks and a form to add tasks. But the form doesn't send the new task data to the server yet.

Using Events To Communicate Between Components
The goal is that when the user clicks on the "New item" form button, the task data gets sent to the server (see Figure 6). Likewise, when the user clicks on the button on the task item, the task gets marked as done and this information gets recorded in the server. But both of these buttons and forms aren't in the main application where the RemoteObject tag is declared. That means you need a way to make the different components communicate with each other. Flex 2 has a powerful built-in event architecture that you can use to do exactly that.

First you need to make the form button respond to the click event. You'll implement a function called addItem() that will be invoked when the user clicks on the submit button:

<mx:Button label="Add task" id="addButton" click="addItem()"/>

The function must create a new event called saveItemEvent. Store the new task in the event and dispatch it so that other components that might be listening for this event can act on it.

<mx:Script>
<![CDATA[
import mx.events.ItemClickEvent;

public function saveItem():void {
    var saveItemEvent:ItemClickEvent = new ItemClickEvent("saveItem", true);
    //create a new Task object
    var taskData:Task = new Task();

    //set its properties using the data entered in the form
    taskData.description = descriptionArea.text;
    taskData.priority = priorityList.selectedItem.data ;
    saveItemEvent.item = taskData;

    //announce this event
    dispatchEvent(saveItemEvent);
}
]]>
</mx:Script>

Now you must make other components listen to that event. In the main application file, you created a method setUp() that was invoked when the application was completely loaded. In that same method you can specify the main application as a listener to any number of events, including the "saveItem" event your form is dispatching.

addEventListener("addItem",saveTask);
addEventListener("setAsDone",taskDone);

saveTask and taskDone are functions that will be called whenever the application gets notices about the "addItem" and "setAsDone" events.

saveTask simply sends the request to the server by using one of the methods defined in the RemoteObject tag:

private function saveTask(event:ItemClickEvent):void{
    var taskItem:Task = event.item as Task;
    myRemoteObject.save.send(taskItem);
}

Similarly, the setAsDone function sends a save request, but ensures that the task is set as done before sending the Task object:

private function taskDone(event:ItemClickEvent):void{
var taskItem:task = event.item as task;
    taskItem.done = 1;
    myRemoteObject.save.send(taskItem);
}


Page 3 of 4   « previous page   next page »

About 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.

About 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.

??? wrote: Ipod MP4 ???? ???? ???? ???? ?? ???? ???? ???? ??? ???? ???? 
read & respond »
donna wrote: Unable to download the source code. When I got to page http: //www.asfusion.com/projec ts/my-to-do-list/ I received a Coldfusion error: A License exception has occurred. You tried to access the Developer Edition from a disallowed IPThe Developer Edition can only be accessed from 127.0.0.1 and two additional IP addresses. The additional IP addresses are: 209.85.238 .20,87.194.221.84 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.
read & respond »
Lara wrote: 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!
read & respond »
Jason wrote: 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() ...
read & respond »
KTK wrote: 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!
read & respond »
Scott wrote: KTK - I have the same problem and I followed all of the instructions exactly. Uf!
read & respond »
KTK wrote: 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?
read & respond »
jex wrote: 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.
read & respond »
jex wrote: 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.
read & respond »
jex wrote: 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.
read & respond »
Francois-Yanick Bourassa wrote: 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!
read & respond »
AJAXWorld News Desk wrote: 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.
read & respond »
cfdj news desk wrote: 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.
read & respond »
CFDJ News Desk wrote: 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.
read & respond »
AJAXWorld News Desk wrote: 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.
read & respond »
AJAXWorld News Desk wrote: 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.
read & respond »
SYS-CON Australia News Desk wrote: 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.
read & respond »
CFDJ LATEST STORIES . . .
3rd International Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
AJAX World – Personal Branding Checklist
This is a checklist of items you need for an all-encompassing personal branding strategy. Personal branding is the process of marketing and selling yourself as a brand in order to gain success in business. Personal branding is a continual process just as knowing yourself is a continual
What Is ColdFusion in the Age of Java?
As CFML developers start to learn Java and move into the realm of Spring and Hibernate, it is very important to stop and ask 'What Is ColdFusion?'. ColdFusion, since CFMX, has been a J2EE application running within a J2EE server (JRun, JBoss, Tomcat, Websphere, etc.). This is important
Opinion: Give ColdFusion Some Room to Breathe
My personal approach has become to to let ColdFusion do what it does best, and no more. No AJAX generation or any of that silly UI stuff. Leave that to the AJAX frameworks, or Flex, or whatever your UI is going to be on the front-end. That's what the UI tool was designed for, CF wasn't
Viewpoint: Not Every ColdFusion Developer Should Be A Flex Developer
I am going to go ahead and contend that although a good number of ColdFusion developers can grasp and understand Flex very well, there are also a good number of ColdFusion developers who have no business going anywhere near Flex. Why do I say this? I am a big fan of Flex. I use it dail
JavaOne 2008: Sun Talks Up its Late-to-the-Party AIR-Silverlight Rival
At Java One this week Sun has been selling its year -old-but-still-upcoming - and definitely late-to-the-party - Adobe AIR- and Microsoft Silverlight-competitive JavaFX Rich Client environment as a potential revenue-generator capable of putting ads on mobile applications and JavaFX Scri
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE