0

Initialize MVVM

asked 2012-06-19 08:06:53 +0800

szarza gravatar image szarza
72 3
http://balteus.blogspot.c...

updated 2012-06-19 08:09:32 +0800

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
        }

...
}

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2012-06-20 18:05:00 +0800

juergenmw gravatar image juergenmw
79 1

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

link publish delete flag offensive edit

answered 2012-06-22 07:38:40 +0800

szarza gravatar image szarza
72 3
http://balteus.blogspot.c...

Thank you.

link publish delete flag offensive edit

answered 2012-06-22 10:29:22 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

You can see an example here
http://emrpms.blogspot.in/2012/06/mvvmlist-itemhibernatemysqlpart-2.html

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-06-19 08:06:53 +0800

Seen: 187 times

Last updated: Jun 22 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More