Data Binding"

From Documentation
Line 2: Line 2:
  
  
In the following sections, we'll cover syntax of all ZK Bind's annotations used on a ZUL. They are all used in '''component's attribute''' and have similar format:
+
In the following sections, we'll cover ZK Bind's annotations used on a ZUL. They are all used in '''component's attribute''' and have general format described in [[ZK_Developer%27s_Reference/Annotations/Annotate_in_ZUML| Annotate in ZUML]]:
 +
 
 +
'''@AnnotationName(''attr-name1=attr-value1, attr-name2=attr-value2'')'''
 +
 
 +
'''@AnnotationName(''attr-name1={attr-value1-1, attr-value1-2}, attr-name2=attr-value2'')'''
 +
 
 +
Basically, the syntax consists of an annotation name with comma-separated key-value pairs. The binder treats an annotation's attribute value as an EL expression, and sets an EL expression without a attribute name to default attribute name "value". All annotations must define default attribute's value.
  
Basically, the syntax consists of an annotation with comma-separated key-value pairs. The binder treats value of a key as an EL expression, and sets an EL expression without a key to default key's value. All annotations requires at least default key's value.
 
  
 
* '''<tt>@</tt>''[AnnotationName]''<tt>( </tt> ''[EvaluateOnce EL-expression]''  <tt>) </tt> '''
 
* '''<tt>@</tt>''[AnnotationName]''<tt>( </tt> ''[EvaluateOnce EL-expression]''  <tt>) </tt> '''

Revision as of 08:17, 3 January 2013


In the following sections, we'll cover ZK Bind's annotations used on a ZUL. They are all used in component's attribute and have general format described in Annotate in ZUML:

@AnnotationName(attr-name1=attr-value1, attr-name2=attr-value2)

@AnnotationName(attr-name1={attr-value1-1, attr-value1-2}, attr-name2=attr-value2)

Basically, the syntax consists of an annotation name with comma-separated key-value pairs. The binder treats an annotation's attribute value as an EL expression, and sets an EL expression without a attribute name to default attribute name "value". All annotations must define default attribute's value.


  • @[AnnotationName]( [EvaluateOnce EL-expression] )
[AnnotationName]
It could be one of [ id | init ]
[EvaluateOnce EL-expression]
The EL expression will only be evaluated once when parsing.
When using with @id, we strongly suggest you to use string literal to give ViewModel's id.



  • @[AnnotationName]( [EL-expression] )
[AnnotationName]
It could be one of [ bind | template | ref ]
[EL-expression]
It could be any ZK allowed EL expression (an internal link to EL) without ${ } enclosed.



  • @[AnnotationName]( [EL-expression], [conditionKeyword]=[EvaluateOnce EL-expression] )
[AnnotationName]
It could be one of [ load | save ]
[conditionKeyword]=[EvaluateOnce EL-expression]
This expression is optional unless you want to save or load upon a command.
[conditionKeyword]
It could be one of [ before | after ]
[EvaluateOnce EL-expression]
The evaluation result must be one or more command name.
Command name must correspond to the name specified in Java annotation @Command in a ViewModel.



  • @[AnnotationName]( [EL-expression], [arbitraryKey]=[EL-expression] )
[AnnotationName]
It could be one of [ command | global-command | validator | converter ]
[arbitraryKey]=[EL-expression]
It's key-value pairs basically. You can write multiple key-value pairs with different key names.
An EL expression without key is set to a default key named "value" implicitly.
Due to each annotation has different functions, some annotations may ignore key-value pair expression other than default key, e.g.@id.
[arbitraryKey]
It could be any name, it's used as a key for parameter related Java annotation in a ViewModel.



Subsections:



Last Update : 2013/01/03

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