sText Semantic Component

Contents

 Introduction

The sText component displays the value of a target attribute of a record as a literal on the canvas.

The first thing an sText component checks when it gets created is to determine what has been defined for its text variable. If something has been defined, the control tries to find a bound attribute within that text. If a bound(s) attribute(s) has been defined within the value of the text, but that no value for this attribute has been found in the target record description, the sText removes itself from the application layout.

If the text variable is null/empty, or if no bound attributes have been defined in the text of the component, the system checks if targetAttributes have been specified. If no such targetAttributes have been defined, the sText component removes itself from the application layout.

 Bound Attribute

If a sText is defined in a MXML file, developers can directly bind a record's description attributes to it (instead of using the targetAttributes parameter). A special markup has been introduced in the Semantic Component Library to give the possibility to bind an attribute value to a particular semantic control, directly in MXML.

The markup that has been introduced are double brackets with the name of the attribute to bind in the middle, such as:

  "[[foaf_name]]"

For the sText Semantic Component, variables can be bound within the text property of the sText component. A bound variable can be the only value of the text property, or it can be part of a complete string.

Here is an example of an attribute bound to a sText component that is used without any other character:

 /** The record has the attribute foaf_name with a value "Bob Garon" */

 

<sText text="[[foaf_name]]" fontWeight="bold" fontSize="14" semanticDataProvider="{data.semanticDataProvider}" />

  /** in the Flex user interface, the value "Bob Garon" will appear for this sText component */

Now here is an example of a bound attribute to a sText component which is part of a string of characters:

 /** The record has the attribute foaf_name with a value "Bob Garon" */

 

<sText text="Name: [[foaf_name]]" fontWeight="bold" fontSize="14" semanticDataProvider="{data.semanticDataProvider}" />

  /** in the Flex user interface, the value "Name: Bob Garon" will appear for this sText component */

 Styles

Style Name Description
sText Style for the main sText component

 AS3 Usage Examples

  /** Create a resultset object instance from the input structXML data */
  var resultset:Resultset = new Resultset(XML(inputData));

  /** Create the sText component */
  var semanticText:sText = new sText();

  /** Initialize the semantic control */
  semanticText.percentWidth = 100;
  semanticText.percentHeight = 100;
  semanticText.semanticDataProvider = resultset;
  semanticText.targetAttributes = ["iron_description"];

  /** Add the sText to the main application */
  this.addChild(semanticText);

 MXML Usage Examples

 <semantic:sText text="[[iron_description]]"
                  width="100%"
                  height="50"
                  semanticDataProvider="{semanticDataProvider}" />

In this example, we assume that the {semanticDataProvider} variable is a Resultset, where the record description is defined, accessible at the creation time of the sText.

 Related Libraries

No related external libraries.