-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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 ?
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
Asked: 2016-06-13 16:23:39 +0800
Seen: 18 times
Last updated: Jun 14 '16