# Difference between ${vm.myMsg} and @init(vm.myMsg) asked 2016-06-13 16:23:39 +0800 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 retag edit ## 2 Answers Sort by » oldest newest most voted answered 2016-06-14 10:27:58 +0800 MDuchemin 1336 1 4 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

WilliamB
1609 1 6

Merci Matthieu ;)

[hide preview]