-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello everyone, I have a question about value loading in the .zul files. What's the difference between @load() and ${}?
What I found is that with $, the casting for the lists does not work, for example when loading values for listbox or combobox. The other and not so obvious thing is that every value that has been loaded with $ cannot be "updated" using "@NotifyChange" annotation from the java/view model part. These two work fine with @load.
Is there a benefit to use ${} instead of @load() when loading something that wont change in some point of usage, e.g. dropdown menus, etc?
Thank you :)
${}
and @init()
are more equal then ${}
and @load()
in your question.
The ${}
is a static reference, who if filled in at another time then the MVVM annotations.
Indeed, it's not a MVVM annotations and also static, so loaded once, never change again.
The @init
is almost the same loaded once, never change again expect if you are working with the if
attribute of a component.
There will work only the ${}
because the if is evaluated before the whole MVVM.
Hope this clears enough.
Hi, sorry for the late reply, as a new user I couldn't post a new answer sooner than 2 days after my first one...
This useful information, thank you! Is there any performance (or other?) benefit to use the static reference ${} instead of @init or @load when the value is needed only for displaying purposes? E.g. faster, lighter?
the static expressions ${} are definitely more-lightweight than the data-binding annotations @load/@init.
${} expressions are replaced almost instantly when the zul is parsed and components are created and no additional mechanics will change them later.
Annotations are parsed as well but only added as meta information to a component (consumes a bit memory). A bit later, when the BindComposer kicks in it will find those annotations and evaluate them - @init() only once, @load() will evaluate initially and again on notify-change or conditional @load(... after/before='command'). This kind of Bind tracking requires additional memory and processing overhead. So if not needed don't use @load and prefer @init or ${}.
A bit similar topic was mentioned in one of our dos and don'ts articles.
short answer: cheaper ${} < @init < @load < @bind more expensive
Asked: 2017-12-18 16:50:32 +0800
Seen: 58 times
Last updated: Dec 22 '17
Problem binding values to a composite component
How to access static member field of a class in zul without zscript
How can i load a constant in .zul
MVVM Validator: class not found ? [closed]
MVVM tab box - delay @load until tab pane displayed?
mvvm, load or save with after or before for seach command
how to fire an event when a variable value loaded through VM
is there any event trigger from zk component on binding ?
ZK team plans to dispose of Composer EventQueues no longer in scope? [closed]