O'Reilly logo

Agile Enterprise Application Development with Flex by Tony Hillerson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Resources As Properties of UI Controls

An even more flexible solution for enhancing components to better support your enterprise framework is the use of a programming technique that we call data styling or Business Style Sheets (BSS), as mentioned earlier. The basic process is to create small files, called resources, and attach them as a property to a regular UI component as well as a DataGrid column.

Example 62 illustrates this BSS technique and contains a small MXML file called YesNoCheckBoxResource.mxml.

Example 62. A CheckBox resource (see YesNoCheckBoxResource.mxml)

<?xml version="1.0" encoding="utf-8"?>
<fx:CheckBoxResource
    xmlns="com.farata.resources" xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:resources="com.theriabook.resources.*"
    offValue = "N"
    onValue = "Y"
    textAlign="center"
    >

</fx:CheckBoxResource>

Doesn’t it look like a style to you? You can easily make it specific to a locale by, for example, changing the on/off values of Y/N to Д/Η, which mean Да/Ηет (which you might be more familiar with as Da/Nyet) in Russian, or Si/No for Spanish. When you think of such resources as entities that are separate from the application components, you begin to see the flexibility of the technique. Isn’t such functionality similar to what CSS is about?

As a matter of fact, it’s more sophisticated than CSS, because this resource is a mix of styles and properties, as illustrated in Example 63. Called StateComboBoxResource.mxml, this resource demonstrates using properties (e.g., dataProvider ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required