Annotate in ZUML"

From Documentation
Line 3: Line 3:
  
 
= Annotate Properties =
 
= Annotate Properties =
To annotate a property, you could specify an annotation expression as the value of the property. In other words, if the value of the property is an annotation expression, it is considered as an annotation for the property, rather than a value be be assigned.
+
To annotate a property, you could specify an annotation expression as the value of the property. In other words, if the value of the property is an annotation expression, it is considered as an annotation for the property, rather than a value to be assigned.
  
 
The format of an annotation expression is <tt>@{''annot-name''(''attr-name1''=''attr-value1, attr-name2=attr-value2'')}</tt>.  That is, an annotation expression is an annotation enclosed with <tt>@{</tt> and <tt>}</tt>.  An annotation consists of a name and a map of attributes which is enclosed with parenthesis. Each attribute is a pair of name-value. For example,
 
The format of an annotation expression is <tt>@{''annot-name''(''attr-name1''=''attr-value1, attr-name2=attr-value2'')}</tt>.  That is, an annotation expression is an annotation enclosed with <tt>@{</tt> and <tt>}</tt>.  An annotation consists of a name and a map of attributes which is enclosed with parenthesis. Each attribute is a pair of name-value. For example,

Revision as of 10:29, 22 July 2011


Annotate in ZUML


Annotations can be applied to the declarations of components and properties in ZUML pages.

Annotate Properties

To annotate a property, you could specify an annotation expression as the value of the property. In other words, if the value of the property is an annotation expression, it is considered as an annotation for the property, rather than a value to be assigned.

The format of an annotation expression is @{annot-name(attr-name1=attr-value1, attr-name2=attr-value2)}. That is, an annotation expression is an annotation enclosed with @{ and }. An annotation consists of a name and a map of attributes which is enclosed with parenthesis. Each attribute is a pair of name-value. For example,

<listitem label="@{bind(datasource='author',value='selected')}"/>

where an annotation called bind is annotated to the label property, and the bind annotation has two attributes: datasource and value.

If the annotation name is not specified, it is assumed to be default. For example, the following two statements are equivalent:

<listitem label="@{datasource='foo'}"/>
<listitem label="@{default(datasource='foo')}"/>

If the attribute name is not specified, it is assumed to be value. For example, the following two statements are equivalent:

<listitem label="@{bind(foo)}"/>
<listitem label="@{bind(value='foo')}"/>

Here is a more complex example.

<listitem label="@{selected.name}"/>

where it annotates the label property with an annotation named default, and the annotation has one attribute whose name and value are value and selected.name, respectively. In other words, it is equivalent to the following code snippet.

<listitem label="@{default(value='selected.name')}"/>

To annotate the same property with multiple annotations, you could specify them one-by-one and separate them with a space, as shown below.

<listitem label="@{ann1(selected.name) ann2(attr2a='attr2a',attr2b)}"/>

Annotate Components

To annotate a component, you could specify an annotation expression in a specific attribute called self as shown below.

<listitem self="@{bind(each=person)}"/>

where self is a keyword to denote the annotation is used to annotate the component declaration, rather than any property.

Version History

Last Update : 2011/07/22


Version Date Content
     



Last Update : 2011/07/22

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.