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 ...

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.