Initialization"
From Documentation
(Created page with "{{ZKDevelopersReferencePageHeader}} The binder is responsible for creating and initializing ViewModel instance. If you want to perform your own initialization in a ViewModel, ...") |
|||
Line 41: | Line 41: | ||
The initial method can retrieve various context object by applying annotation on its parameter, please refer [[ZK Developer's Reference/MVVM/Advance/Parameters]]. | The initial method can retrieve various context object by applying annotation on its parameter, please refer [[ZK Developer's Reference/MVVM/Advance/Parameters]]. | ||
+ | |||
+ | =Version History= | ||
+ | {{LastUpdated}} | ||
+ | {| border='1px' | width="100%" | ||
+ | ! Version !! Date !! Content | ||
+ | |- | ||
+ | | 6.0.0 | ||
+ | | February 2012 | ||
+ | | The MVVM was introduced. | ||
+ | |} | ||
{{ZKDevelopersReferencePageFooter}} | {{ZKDevelopersReferencePageFooter}} |
Revision as of 01:40, 9 February 2012
The binder is responsible for creating and initializing ViewModel instance. If you want to perform your own initialization in a ViewModel, you can declare your own initial method by applying @Init on it. Binder will invoke this method when initializing a ViewModel. Each ViewModel can only have one initial method.
public class MyViewModel {
@Init
public void init(){
//initialization code
}
}
This annotation has an element "upward", if you set it to "true". The binder will look for the initial method of ViewModel's parent class and invoke it first if it exists.
public class ParentViewModel{
@Init
public void init(){
//initialization code
}
}
public class ChildViewModel extends ParentViewModel{
@Init(upward=true)
public void init(){
//initialization code
}
}
- ParentViewModel's initial method is invoked first then ChildViewModel's.
The initial method can retrieve various context object by applying annotation on its parameter, please refer ZK Developer's Reference/MVVM/Advance/Parameters.
Version History
Version | Date | Content |
---|---|---|
6.0.0 | February 2012 | The MVVM was introduced. |