Initialization"
m ((via JWB)) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{ZKDevelopersReferencePageHeader}} | {{ZKDevelopersReferencePageHeader}} | ||
+ | {{Deprecated | url=[http://books.zkoss.org/zk-mvvm-book/8.0/data_binding/initialization.html zk-mvvm-book/8.0/data_binding/initialization]|}} | ||
− | We can initialize any component's attribute by initial binding: < | + | We can initialize any component's attribute by initial binding: <code>@init</code>. It loads ViewModel's property once at the beginning then the property won't be synchronized by binder during user interaction. But EL evaluation's result we expect in initial binding annotation is different for attribute "viewModel" and "form". |
= @init at viewModel Attribute = | = @init at viewModel Attribute = | ||
− | The first place we usually use this annotation is to assign a ViewModel to a component in viewModel attribute. When using in viewModel attribute, we should specify the '''full-qualified class name''' in a string literal in < | + | The first place we usually use this annotation is to assign a ViewModel to a component in viewModel attribute. When using in viewModel attribute, we should specify the '''full-qualified class name''' in a string literal in <code>@init</code>. |
<source lang="xml"> | <source lang="xml"> | ||
Line 42: | Line 43: | ||
</source> | </source> | ||
− | We'll describe more advanced usage with < | + | We'll describe more advanced usage with <code>@init</code> in section [[ZK Developer's Reference/MVVM/DataBinding/Form Binding]]. |
=Version History= | =Version History= | ||
− | + | ||
− | {| | + | {| class='wikitable' | width="100%" |
! Version !! Date !! Content | ! Version !! Date !! Content | ||
|- | |- |
Latest revision as of 07:35, 8 July 2022
This article is out of date, please refer to zk-mvvm-book/8.0/data_binding/initialization for more up to date information.
We can initialize any component's attribute by initial binding: @init
. It loads ViewModel's property once at the beginning then the property won't be synchronized by binder during user interaction. But EL evaluation's result we expect in initial binding annotation is different for attribute "viewModel" and "form".
@init at viewModel Attribute
The first place we usually use this annotation is to assign a ViewModel to a component in viewModel attribute. When using in viewModel attribute, we should specify the full-qualified class name in a string literal in @init
.
<window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('foo.MyViewModel')">
</window>
The composer will resolve the string 'foo.MyViewModel' and create a object of it.
@init at Component's Attribute
It's common to use it to initialize a component's attribute with a constant value or a ViewModel's proeprty. The binder loads it once and doesn't synchronize it afterward during following user interaction.
<label value="@init(vm.message)"/>
<label value="@init(123)"/>
<checkbox checked="@init(true)"/>
@init at Form Binding
We can also use the initial binding on the form binding to fill in predefined value.
<div form="@id('fx') @init(vm.defaultOrder) @load(vm.order) @save(vm.order, before='compute')">
</div>
We'll describe more advanced usage with @init
in section ZK Developer's Reference/MVVM/DataBinding/Form Binding.
Version History
Version | Date | Content |
---|---|---|
6.0.0 | February 2012 | The MVVM was introduced. |