Note: The book excerpt linked to below is from Chapter 18 of Developing Rich Clients with Macromedia Flex by Alistair McLeod and Steven Webster, published by Macromedia Press.
The introduction of Rich Internet Applications (RIAs) has meant the moving of processing—once done on an application server—to the user’s desktop. With that processing, data has also moved over the wire to be processed on client machines before being sent back for storage on the enterprise data stores.
Data binding is an ideal candidate solution for the updating of a user interface from a client-side model, and vice versa. This transfer of data between client-side layers, such as between the client-side model and the view (user interface controls) and vice versa, is something developers might have traditionally implemented by using simple but repetitive manual coding techniques. Thankfully, Flex gives you a powerful feature to aid in this process: data binding. Data binding is the process of tying the data in one object (the source) to another object (the destination).
When the source object is changed, those changes are automatically reflected in the destination object. In this chapter, you’ll learn about the following:
Data binding can be used wherever you want one object to reflect the changes in another. Some common usages include
<mx:Model>, <mx:Object>, or an ActionScript 2.0 class. That model can then be bound to a web service or remote object request.Learn about this and more by downloading and reading the chapter excerpt.
Below is important errata that the authors have provided for Chapter 18 of the published book.
The authors would like to acknowledge Dan Harfleet for compiling the errata for this chapter. For further information on migration issues between Flex 1.0 and Flex 1.5, the authors suggest reading "Migrating Flex Applications" in the Flex documentation.
widthFlex and heightFlex attributes (pages 396, 397, 398, 399, 400, 408, 409, 411, 412, and 413) – Setting percentage width and height values: Width and height values can now be set as a percentage, the value being the percentage of the parent container that the component should span. (See "Migrating Flex Applications" in the Flex documentation.)<mx:VSlider/> and <mx:HSlider/> (Vertical and Horizontal slider controls).TextArea control (pages 399, 400, 408, 410, 411, 412, and 413) – Parent container sizing rules have changed. Parent containers do not expand to fill their parent automatically; they only expand enough to take up the space needed by its child, therefore you must explicitly set width and height percentages.DataGrid control ( see note 5 ) (pages 410, 412, and 413) – The label function for DataGrid control has changed. In Flex 1.0, the labelFunction attribute of DataGridColumn only took one argument, which was the data to be formatted/operated on; now the function takes two arguments, the data and the datagrid column name. This allows the same function to alter its behavior if necessary dependent on the column. The example on page 411 to 413 should have the label function changed to:
function formatBalance( item, columnName )
{
.......
To complete this tutorial you will need to install the following software:
Steven Webster and Alistair McLeod, Developing Rich Clients with Macromedia Flex, © 2005 iteration::two. Reproduced by permission of Pearson Education, Inc. publishing as Peachpit Press. All Rights Reserved.
Steven Webster is a technical director at iteration::two, a world-leading Rich Internet Application consultancy based in Edinburgh, Scotland. Steven is the author of Reality J2EE: Architecting for Flash MX and coauthored ActionScript 2.0 Design Patterns for Rich Internet Applications (ActionScript 2.0 Dictionary) and Developing Rich Clients with Macromedia Flex with Alistair McLeod. Steven speaks regularly at conferences and user group meetings on technical and business aspects of RIAs. Steven is the core contributor to the open-source Cairngorm project, a micro-architecture for RIAs based on J2EE patterns which was innovated by iteration::two over a number of Flash and Flex RIA developments.
Alistair McLeod is a development director at iteration::two, a world-leading Rich Internet Application consultancy based in Edinburgh, Scotland. Alistair coauthored ActionScript 2.0 Design Patterns for Rich Internet Applications (ActionScript 2.0 Dictionary) and Developing Rich Clients with Macromedia Flex with Steven Webster, and has spoken at industry conferences, including Macromedia MAX. A strong advocate of agile software development, Alistair is the core contributor to both the AS2Unit and FlexUnit unit-testing frameworks for the test-driven development of Rich Internet Applications. Alistair has led the development of several RIA projects into production, including the first European deployment of a Macromedia Flex project.