0

@SelectorParam in @Init method of a viewmodel

asked 2012-09-17 10:04:53 +0800

deggesim gravatar image deggesim
36 1

updated 2012-09-17 10:07:07 +0800

Starting from ZK 6.0.2.1 (actually I'm evaluating 6.5 version) I have problems with value of parameters passed to init methods of a viewmodel.
I used the example in the documentation of @SelectorParam (http://books.zkoss.org/wiki/ZK%20Developer's%20Reference/MVVM/Syntax/ViewModel/Parameters/@SelectorParam) and modified the code of the VM to test the issue:

public class SelectorParamVM {
	
	@Init
	public void myInit(@SelectorParam("label") LinkedList<Label> labels, @SelectorParam("#message") Label msg) {
		for (int i = 0; i < labels.size(); i++) {
            labels.get(i).setValue("Command " + i);
        }
        msg.setValue("init");
	}
	
	@Command
    public void cmd(@SelectorParam("label") LinkedList<Label> labels, @SelectorParam("#message") Label msg) {
        for (int i = 0; i < labels.size(); i++) {
            labels.get(i).setValue("Command " + i);
        }
        msg.setValue("msg in command");
    }
}

labels and msg are null in myInit.
Why?

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2012-09-17 10:29:36 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

Use @AfterCompose, when @Init, it is too early to get subsequence children component.

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-09-17 10:04:53 +0800

Seen: 91 times

Last updated: Sep 17 '12

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