Difference between ${vm.myMsg} and @init(vm.myMsg)

asked 2016-06-13 16:23:39 +0800

WilliamB gravatar image WilliamB
1609 1 6

This might sound like a silly question, I know that they are filled at different period during the rendering phase. But in the end they define a value which never change.

Which one to use and when, and what is the difference between these 2 expressions ?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2016-06-14 10:27:58 +0800

MDuchemin gravatar image MDuchemin
2390 1 6
ZK Team

updated 2016-06-14 11:03:50 +0800

Hi William,

The main difference would be that @init() requires a Binder or BindComposer.

While they are both cheap, ${} is a tiny bit cheaper since there is no memory overhead. Unless you have extremely large amounts of Expressions in a context, the difference should not be noticeable.

As you mentioned, @init() happen during bind, which is after zul parsing. ${} are evaluated during parsing. Due to this, you can reference a component further down a zul page in @init, but not in ${}.

Otherwise, they provide the same function: one-time evaluation of an expression during page initialization, without maintaining a tracking entry afterward.

PS: that's a good addition to the do's and don't, so I will also reply there ;-) Regards, Matt

Edit: corrected the obvious classname error BinderComposer > BindComposer

link publish delete flag offensive edit

answered 2016-06-14 10:33:32 +0800

WilliamB gravatar image WilliamB
1609 1 6

Merci Matthieu ;)

link publish delete flag offensive edit
Your answer
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

1 follower



Asked: 2016-06-13 16:23:39 +0800

Seen: 18 times

Last updated: Jun 14 '16

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