SHBox
From TechWiki
Contents |
Introduction
The sHBox Semantic Component can be used for different purposes. It is primarily used to display information about specific records. In this case, we talk about a record box: a canvas where we display all information relative to a target record.
In other cases, it is used as a display container that has some additional behavior with the required attribute of each of its child Semantic Component.
Record Box
Sometimes, a sHBox is used to display all of the information related to a target record. When that is the case, the sHBox is declared to be a record box. A record box is a canvas where all the information about a target record gets displayed. This canvas is part of an application layout. Multiple record-box canvases can belong to the same application, at the same time.
Only one sGenericBox can be defined in a record-box.
Required
The required variable of each semantic component is used by the canvas Semantic Component such as this sHBox component. Sometimes, we use a HBox as a way to "bundle" one or multiple Semantic Components together. These components are then used to display one or more values of one or more bounded attribute(s). In some cases, the child control of such a sHBox is not bound to any attribute/value of a target record, because the record's description lacks this information.
In such a use case, the sHbox doesn't display any useful information about the record(s). Since it doesn't display any useful information, then it will simply remove itself from the application layout.
Here is a MXML example of this attibute in action:
paddingLeft="7"
semanticDataProvider="{data.semanticDataProvider}">
<semantic:sImage
required="false"
source="images/page_white_code.png" />
<semantic:sText
text="Programming language: [[cosmo_language]]"
semanticDataProvider="{data.semanticDataProvider}" />
</semantic:sHBox>
In this use case, the sHBox is used to "bundle" a semantic image component with a semantic text component. The image should only be rendered if something is rendered for the sText component. It is why the sImage is marked as not-required (require=false).
Here is another use case to illustrate what may happen with when using the sHBox. The target record of the sHBox doesn't have the "cosmo_language" attribute. This means that the sText control will simply remove itself from the application layout because it doesn't display any value of the target record. Since the sText component removed itself, the layout now looks like:
paddingLeft="7"
semanticDataProvider="{data.semanticDataProvider}">
<semantic:sImage
required="false"
source="images/page_white_code.png" />
</semantic:sHBox>
Now, the only child component of the sHbox is a non-required component. Since no required component is a child of the sHBox, the sHBox will simply remove itself from the layout of the application.
This is helpful for the developer, since even if she defined these 3 components in her layout, she doesn't have to do anything to clean it in the case that an attribute does not exist in the description of a target record. It simply removes itself, without leaving an image without meaningful information beside it.
Styles
| Style Name | Description |
| sHBox | Style for the main sHBox component |
AS3 Usage Examples
var resultset:Resultset = new Resultset(XML(inputData));
/** Create the sHBox component */
var semanticHBox:sHBox = new sHBox();
/** Initialize the semantic control */
semanticHBox.percentWidth = 100;
semanticHBox.percentHeight = 100;
semanticHBox.semanticDataProvider = resultset;
semanticHBox.isRecordBox = true;
/** Add the sHBox to the main application
this.addChild(semanticHBox);
MXML Usage Examples
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 sHBox.
Related Libraries
No related external libraries.