![]() | ![]() ![]() ![]() |
![]() | |
![]() | |
![]() |
The Schema tab allows you to view the schema for the selected component. The schema contains a list of the component's bindable properties, their data types, their internal structure, and various special attributes. This is the information that the data binding feature needs in order to handle your data correctly.
The Schema Tree pane, the top pane of the Schema tab, displays the bindable properties of the selected component and their internal structure, represented by one or more schema fields (component properties and schema fields are also referred to as schema items). The Schema Attributes pane, the bottom pane of the Schema tab, displays detailed information about the selected schema item.
Note: All components have properties, but by default, to reduce UI clutter, the Schema tab shows only those properties that commonly contain dynamic data. These properties are referred to as bindable properties. You can bind to any property by either adding it to the schema panel yourself or using ActionScript code. See Working with bindings in the Bindings tab (Flash Professional only).
A component's schema describes the structure and type of data but is independent of how the data is actually stored. For example, the results from a WebServiceConnector component or an XMLConnector component could have identical schemas, even though the web service results are stored as ActionScript data structures (objects, arrays, strings, Boolean values, and numbers), and the XMLConnector component results are stored as XML objects. When you use data binding to access fields within a component's schema, you use the same procedure regardless of how the data are stored.
A component identifies which of its properties are bindable. These bindable properties appear in the Schema panel as top-level schema items (component properties). A component property can have its own internal structure (schema) that defines additional properties (schema fields) that can be bound to other component properties within your application. A good example of this is when you introspect a WSDL for a WebServiceConnector component. The WSDL definition describes the parameters and the results for a web service. The WebServiceConnector component contains two bindable properties (params
and results
). When the WebServiceConnector component introspects, the WSDL the authoring tool automatically creates the schema for the params
and results
properties so that it mirrors the schema defined within the WSDL.
There are several ways to create the schema for a component:
When you import a sample XML file to use as a schema, Flash MX Professional 2004 examines the sample document and creates a schema that represents the nesting structure of the document's XML elements and attributes, as well as the data type (number, Boolean value, or string) of the text values. Any element that occurs more than once appears in the schema as an array.
The schema appears in the Schema tab. You can now create a binding between your XML element and the component property within your application.
Note: Some XML documents may have a structure that Flash MX Professional 2004cannot representfor example, elements that contain text and child elements mixed together.
Use the following procedure to add a schema field to a schema item.
A new field is added as a subfield of the selected property.
There are three possible scenarios based on the type of schema item:
You can make any of your component properties bindable if you add them to the schema. The following procedure explains how to create an application that uses a CheckBox component to indicate whether a TextInput component is editable. However, in this example, the editable
property of the TextInput component is not bindable, so its schema must be modified.
editable
property, and click OK.The schema of a component shows you what properties and fields are available for data binding. For each property or field, there are settings that control validation, formatting, type conversion, and other features that affect how data binding and the data management components handle the data of a field. The Schema Attributes pane, the bottom pane of the Schema tab, presents these settings, which you can view and edit. Settings fall into five groups, according to the features they control:
Basic settings Every field or property has these basic schema settings. In many cases, these are the only settings you need to bind to a field.
Note: Developers will almost never have to change this setting. However, there are some cases when the storage type for an attribute contained within the schema for an XML file may be defaulted to scalar when it should be set to attribute.
Validation settings Validation settings are applicable to any field that is the destination of a binding. You will usually modify these settings when you want to control the validation of data that is input by the end user. To set this up, you bind from the UI component to a data component, and then select appropriate validation settings for the fields of the data component. One common example is when the user input is bound to the params
property of a connector component, such as the XMLConnector component or WebServiceConnector component. Another common example is when UI components are bound to data fields of the DataSet component.
Validation operates in the following way: After any binding is executed, the new data is checked according to the validation rules of the destination field's data type. A component event is then generated to signal the results of the checking. If the data is found to be valid, then the valid event is generated; otherwise, an invalid event is generated. Both components involved in the binding emit the event. You can ignore these events. If you want anything to happen as a result of these events (such as giving feedback to the end user), you must write some ActionScript code that receives the valid and/or invalid events.
required=true
but no value has been set.readonly=true
, then executing any binding to this field generates the invalid event, and the field is changed.Formatter settings Formatter settings are applied when a field's value needs to be converted to a string. Most often this will be for display purposes, such as when a DataSet field is databound to the text
property of a Label or TextArea component. Formatter settings on a field are ignored when that field is databound to something whose data type isn't String.
true
and false
values.Note: If you don't specify a formatter, then a default conversion is applied when a field's value is needed as a string.
For a complete list of formatters, see Schema formatters (Flash Professional only).
Kind and Encoder settings The Kind and Encoder settings are used to activate certain special features. For information, see Using kinds and encoders.
Default settings These settings let you set defaults for various situations. There are two uses for these settings:
results
property of a connector component, are allowed to have an undefined value. When you build an application using data components and/or data binding, you need to apply schema item settings to some, but not necessarily all, fields of the components in your application. The following table summarizes the most common uses of schema item settings and will help you determine when these settings need to be edited.
Component |
Property/field |
Settings |
When to use |
---|---|---|---|
Any connector |
|
Validation Options, Read-Only, Required |
If validation is desired |
|
Formatter, Formatter Options |
For fields that need formatting for display as text |
|
Default value |
For fields whose value is sometimes undefined |
||
DataSet |
Any data field |
Name, Data Type |
You must set these for every data set field that you define |
Validation Options, Read-Only, Required |
If validation is desired |
||
Formatter, Formatter Options |
For fields that need formatting for display as text |
||
Default Value |
For fields whose value is sometimes undefined, or to specify the initial value for newly created data set records |
||
UI components |
UI components typically don't need any changes to their schema settings |
||
Any component |
Any property or field |
Kind, Kind Options, Encoding, Encoding Options |
Various purposes, as described in Using kinds and encoders |
Any connector |
|
Path |
To identify the location of the data for a virtual schema field |
Kinds and encoders are drop-in modules that perform additional special processing of the data of a schema item. They are often used in conjunction with each other to accomplish common tasks. Below is a list of common uses for kinds and encoders.
Calculated DataSet Fields Calculated fields are virtual fields that do not exist in the underlying data tables. Calculated fields provide developers with the ability to create and update dynamic field values at runtime. This is especially convenient for calculating and displaying values based on calculations or concatenations performed other fields located in a record (for instance, you can create a calculated field that combines the first and last name fields together to display the full name to a user).
calcFields
event of the DataSet component to assign this field a value at runtime.
Note: You should assign a value to a calculated field only within the DataSet component's calcFields
event.
Setting up schemas for XML documents In an XML document, all data is stored as a string. Sometimes you want the fields of an XML document to be available as data types other than String. The following example shows an application that pulls in data from an XML file.
<datapacket> <row id="1" billable="yes" rate="50" hours="3" /> <row id="2" billable="no" rate="50" hours="6" /> </datapacket>
If you use this XML file to import a schema for the XMLConnector component's results
property, it generates the following:
results : XML datapacket : Object row : Array [n] : object @billable: Boolean @hours : Integer @id : Integer @rate : Integer
But suppose you want to treat the row node as a record within a grid, and you want the @billable
attribute to be treated as a Boolean value and display a true
or false
value in the grid instead of a yes
or no
. Getting the data into the grid is simple. You can simply bind the row schema field to the dataProvider
property of the grid. The following procedure explains how to get the @billable
attribute to be treated as a Boolean value and display a true
or false
value.
encoder
property in the Schema Attributes pane.true
value and which strings represent a false
value.true
and enter no for strings that you want to set to false
.
The encoder now takes the XML data in its raw form (String) and converts it into its normal form (ActionScript type of Boolean). Using the encoder options, it knows how to encode the string values correctly.
true
and false
value should be displayed as a string.true
and enter False for strings that mean false
.
The formatter now takes the normal form (ActionScript type Boolean) and formats it into the String value true
or false
for display purposes.
The path
property for a schema field is an optional setting that is used in special circumstances when the schema for your component is not appropriate. Using this setting, you can create a virtual schema field (a field that exists in one location but pulls its value from another). The value of this property is a path expression that is entered in one of the following formats:
field [.field]...,
where field
is equal to the name of a field (such as addresslist.street
).XPath,
where XPath
is a standard XPath statement (such as addressList/street
).When data binding is performed, Flash checks to see if there is a path expression for a schema field. If there is, it uses the path expression to locate the correct value. See Virtual XML schemas.
Note: The path expression is always performed relative to the parent node of the schema field.
You can edit anything within the Schema Attributes paneeven schemas that came from an external source, such a web service WSDL file. You can always change any value for any field of any schema, with the following restrictions:
Note: There are several ways to reload the schema for a component property, including entering a new WSDL URL, choosing a different operation for a web service, or importing a new XML schema from a sample XML file.
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |