Data Binding

From Documentation


In the following sections, we'll cover syntax of all ZK Bind annotation used on a ZUL. They are all used in component's attribute and have similar format:

Basically, the syntax is 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.

  • @[Annotation]( [EvaluateOnce EL-expression] )
[Annotation]
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.



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



  • @[Annotation]( [EL-expression], [conditionKeyword]=[EvaluateOnce EL-expression] )
[Annotation]
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.



  • @[Annotation]( [EL-expression], [arbitraryKey]=[EL-expression] )
[Annotation]
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 : 2012/02/08

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