| By Ian Bale | Article Rating: |
|
| November 17, 2006 02:30 PM EST | Reads: |
22,822 |
Notice though that rather than validate the input controls themselves I'm validating userdata. This is a data model that holds all the user data in one object, and it is this that's passed back to the parent window after saving.
<mx:Model id="userdata">
<user>
<name>{namefield.text}</name>
<phone>{phonefield.text}</phone>
<email>{emailfield.text}</email>
</user>
</mx:Model>
This in turn is bound to the input controls, and as such is always "up-to-date." Validation is handled using the Flex validation controls:
<mx:StringValidator field="userdata.user.name"/>
<mx:PhoneNumberValidator field="userdata.user.phone"/>
<mx:EmailValidator field="userdata.user.email"/>
This ensures that the user supplies required data and that the telephone number and e-mail address are correctly formatted. Assuming that the user supplies all the correct data then the save function eventually passes the data back to the parent window before closing itself. It does this by using the parentref that our main form passed when it opened the window and calls the public function that we created there to get the updated data.
parentref.setUserData(userdata.user);
The setUserData function in Demo5.mxml simply assigns the data objects passed to it to userObj, the object to which our Label fields are bound, so they immediately update with the newly saved values.
Now for a few "gotchas" that you'd might like to watch out for. The first is the pop-up window's close button. You'll notice in the code that I disable the entire TitleWindow control when I'm saving to prevent the user from making any further changes or pressing submit a second time. That works great, but the close button is always active. Function closePopup checks the window's enabled status prior to closing.
In this example the window closes just fine. However, there's a well-known Flex bug whereby, if you close a pop-up window with a drop shadow in the response handler of a remoting call then the window is removed but the drop shadow remains behind (see Figure 7).
One solution is simply to use styles to disable the default drop shadow. If, however, you'd like to use the drop shadow then these two lines of code will sort the problem out for you:
windowObject.setStyle("dropShadow",false);
windowObject.redraw(true);
The first simply removes the drop shadow. We do this before closing the window. The second is needed because of the way flash does its redraws. Without it you'll find that the window is closed before the drop shadow is removed. The code forces an immediate redraw. See Listing 8 for an example that uses remoting. Simply comment out those two lines to see the shadow bug in action. Listing 9 is a very simple CFC that handles the saveUser function.
Finally, few other things to note:
- In userEditForm.mxml (Listings 7/8), you'll notice the <mx:TitleWindow> tag has a modalTransparency attribute that I've set to "75." This makes everything behind the pop-up window 75% transparent. This looks great and is a clear indicator to the user that the remaining application is disabled while the pop-up is open. See Figure 5.
- You can center your pop-up by adding this.centerPopUp() to your load attribute.
Published November 17, 2006 Reads 22,822
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Ian Bale
Ian Bale is co-director of Celtic Internet ltd. (www.celticinternet.com), a UK-based software engineering and consultancy company. Ian has worked as a consultant since 1989 in both the telecom and Internet industries.
![]() |
Pim 11/21/06 06:53:17 PM EST | |||
I was wondering one thing, when you use flash forms and submit data to another cfm page, values are accessible as if they were normal forms (form.firstname, form.address ...), what happens in this case ? Would you have to use remoting to submit them ? |
||||
![]() |
Fritz Dimmel 11/21/06 09:19:26 AM EST | |||
Hi! Thanks, |
||||
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe Flex Developer Earns $100K in New York City
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Adobe Cans Another 9% of its Workforce
- Moyea DVD4Web Converter V2.0 Converts DVD to FLV Fast and Synchronously with Watermarks
- Adobe Fiddles with its Web Apps
- Adobe & Salesforce Cut Cloud Deal
- Hosting.com Launches ColdFusion 9 in the Cloud
- The Real Time Infrastructure Ultimatum
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- The Planet Named “Bronze Sponsor” of Cloud Computing Expo
- Microsoft Expression Web Has Got Game
- Adobe Flex Developer Earns $100K in New York City
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Bruce Chizen Joins Voyager Capital as Venture Partner
- My Top Seven Wishes From Adobe MAX 2009
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- Has the Technology Bounceback Begun?
- Building a Zip Code Proximity Search with ColdFusion
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- The Asynchronous CFML Gateway
- Web Services Using ColdFusion and Apache CXF





























