Data Forms
In this section, you’ll continue adding components to the enterprise
framework. It’s hard to find an enterprise application that does not use
forms, which makes the Flex form component a perfect candidate for
possible enhancements. Each form has some underlying model object, and the
form elements are bound to the data fields in the model. Flex 3 supports
only one-way data binding: changes on a form automatically propagate to
the fields in the data model. But if you want to update the form when the
data model changes, you have to manually program it using the curly braces
syntax in one direction and BindingUtils.bindProperty()
in
another.
Flex 4 introduces a new feature: two-way binding. Add an @ sign to
the binding expression (@{expression}
)
and notifications about data modifications are sent in both
directions—from the form to the model and back. Although this helps in
basic cases where a text field on the form is bound to a text property in
a model object, two-way binding doesn’t have much use if you’d like to use
data types other than String
.
For example, two-way binding won’t help that much in forms that use
the standard Flex <mx:CheckBox>
component. What are you going to bind here? The server-side application
has to receive 1 if the CheckBox
was
selected and 0 if not. You can’t just bind its property selected
to a numeric data property on the underlying object. To really appreciate two-way binding, you need to use a different set of components, similar to the ones ...
Get Agile Enterprise Application Development with Flex 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.