@converter"

From Documentation
m ((via JWB))
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{ZKDevelopersReferencePageHeader}}
 
{{ZKDevelopersReferencePageHeader}}
 +
{{Deprecated | url=[http://books.zkoss.org/zk-mvvm-book/8.0/syntax/converter.html zk-mvvm-book/8.0/syntax/data_binding/converter]|}}
  
  
 
=Syntax=
 
=Syntax=
  
<tt> @converter(</tt> ''[EL-expression], [arbitraryKey]=[EL-expression] '' <tt>) </tt>
+
<code>@converter(</code> ''[EL-expression], [arbitraryKey]=[EL-expression] '' <code>)</code>
  
 
= Description =
 
= Description =
'''Target Attribute:''' any (except viewModel, validationMessages, form, and even attributes)
+
'''Target Attribute:''' any (except viewModel, validationMessages, form, and event attributes)
  
'''Purpose:''' It should be used with <tt> @bind </tt>, <tt> @load </tt>, <tt> @save </tt>. It applies a converter to convert data during transformation between UI components and ViewModel.
+
'''Purpose:''' It should be used with <code>@bind</code>, <code>@load</code>, <code>@save</code>. It applies a converter to convert data during transformation between UI components and ViewModel.
  
 
The evaluation result of EL expression should be a <javadoc> org.zkoss.bind.Converter </javadoc> object. You can append arbitrary arguments in key-value pair with comma separated to pass it to the Converter object. Built-in Converter is referenced by a string literal as its name.
 
The evaluation result of EL expression should be a <javadoc> org.zkoss.bind.Converter </javadoc> object. You can append arbitrary arguments in key-value pair with comma separated to pass it to the Converter object. Built-in Converter is referenced by a string literal as its name.
Line 34: Line 35:
 
<label value="@load(vm.selected.totalPrice) @converter(vm.totalPriceConverter)"/>
 
<label value="@load(vm.selected.totalPrice) @converter(vm.totalPriceConverter)"/>
 
</source>
 
</source>
 +
 +
 +
 +
 +
=Version History=
 +
 +
{| class='wikitable' | width="100%"
 +
! Version !! Date !! Content
 +
|-
 +
| 6.0.0
 +
| February 2012
 +
| The MVVM was introduced.
 +
|}
  
  
  
 
{{ZKDevelopersReferencePageFooter}}
 
{{ZKDevelopersReferencePageFooter}}

Latest revision as of 07:35, 8 July 2022

Stop.png This article is out of date, please refer to zk-mvvm-book/8.0/syntax/data_binding/converter for more up to date information.


Syntax

@converter( [EL-expression], [arbitraryKey]=[EL-expression] )

Description

Target Attribute: any (except viewModel, validationMessages, form, and event attributes)

Purpose: It should be used with @bind, @load, @save. It applies a converter to convert data during transformation between UI components and ViewModel.

The evaluation result of EL expression should be a Converter object. You can append arbitrary arguments in key-value pair with comma separated to pass it to the Converter object. Built-in Converter is referenced by a string literal as its name.

[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.

Example

Use built-in converter named formatedNumber

<label value="@load(item.price) @converter('formatedNumber', format='###,##0.00')"/>

Use custom converter

<label value="@load(vm.selected.totalPrice) @converter(vm.totalPriceConverter)"/>



Version History

Version Date Content
6.0.0 February 2012 The MVVM was introduced.




Last Update : 2022/07/08

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