
64
Chapter 4: Architecting Flex Applications
Separating your data model from your view
To cleanly separate the user interface, application-specific data, and data services, you can use Flex
data models that store data between controls and data services. This type of three-tier design is
applicable to both input data and data service results.
When you plan an application, you determine the kinds of data that the application must store
and how that data must be manipulated. This helps you decide what types of data models you
need. For example, suppose you decide that your application must store data about employees. A
simple employee model might contain name, department, and e-mail address properties.
A Flex
data model
is an ActionScript object that contains properties that you use to store
application-specific data. You can use a data model for data validation, and it can contain client-
side business logic. You can define a data model in MXML or ActionScript. In the model-view-
controller (MVC) design pattern, the data model represents the model tier.
You can define a data model in an MXML tag, ActionScript function, or an ActionScript class. A
model written in MXML is useful for rapid development and simple data storage, but it does not
provide any additional functionality, and you cannot set the data types of the model’s properties.
You should use an ActionScript-based class if you want to set data types and provide methods for
additional functionality. In general, you should use MXML-based models for simple data
structures and use ActionScript for more complex structures and client-side business logic.
Working with data services
Flex is designed to interact with several types of services that provide access to local and remote
server-side logic. For example, a Flex application can connect to a web service that uses the Simple
Object Access Protocol (SOAP), a Java object residing on the same application server as Flex using
AMF, or an HTTP URL that returns XML. AMF is the protocol used in Flash Remoting MX.
The MXML components that provide data access are called data service components. MXML
includes the following types of data service components:
•
WebService
provides access to SOAP-based web services.
•
HTTPService
provides access to HTTP URLs that return data.
•
RemoteObject
provides access to Java objects (Java Beans, EJBs, POJOs) using the AMF
protocol.
Data formatter
Converts raw data to a formatted string. Formatters are triggered just before data is
displayed in a text field. They can save you time by automating data formatting
tasks, and by letting you easily change the formatting of fields within your
applications.
Data binding
Copies data stored in one object to another object. For example, you can bind data
from the fields of a user input form to fields in a data service request. To display
data that a data service returns, you can bind fields from the data service result to
user interface controls.
Feature
Description
Summary of Contents for FLEX-GETTING STARTED WITH FLEX
Page 1: ...Getting Started with Flex...
Page 4: ...4 Contents...
Page 22: ...22 Chapter 1 Introducing Flex...