Chapter 16. Modeling and Managing Data
Flex applications are stateful; that is, they have the ability to remember data persistently for the duration of the user's session in a way that classic Web applications usually don't. One of the most common tasks you must accomplish as an application developer is to create a framework for storing data that the application can use at runtime.
The content of an application's data can come from many sources: XML files, databases or other server-side resources, or remote functions wrapped by and exposed as SOAP-style or REST-style Web services. Regardless of how the data comes to an application, though, a Flex application stores the data in exactly the same way: as a data model.
In this chapter, I describe common techniques for modeling data in Flex applications. I start with creating single-object data models: ActionScript classes designed to hold one instance of a data entity at a time. (A data instance might represent a row in a database table or a single element in an XML file.) You can represent such data instances with the <mx: Model>
tag, a generic data object, or more commonly you create your own custom ActionScript classes, known by the various design pattern names Value Object and Transfer Object.
In the second part of the chapter, I describe the use of data collections: ordered collections of data instances managed by the ArrayCollection
class. I describe how and where to declare the ArrayCollection
and then describe how to use this powerful ...
Get Adobe® Flex® 3 Bible now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.