-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello:
What strategy is best for initialize ViewModel? Constructor, onCreate method, or "@Init" annotated method?
"@Init" annotated method can have BindContext argument?
public class SampleVM { @Command public void onCreate(BindContext ctx) { self = ctx.getComponent(); init_or_load_data_method(); } public SampleVM() { init_or_load_data_method(); } @Init public init_or_load_data_method() { // ... do work } ... }
Hi szara
There is no "best" strategy.
If you wanna pass an Argument (your 2nd question) it is best to use @Init and ExecutionArgParam - see Syntax/ViewModel/Parameters/@ExecutionArgParam
BR
Thank you.
You can see an example here
http://emrpms.blogspot.in/2012/06/mvvmlist-itemhibernatemysqlpart-2.html
Asked: 2012-06-19 08:06:53 +0800
Seen: 187 times
Last updated: Jun 22 '12