Search code examples
elzkref

What difference between @load() and ${}


code:

<zk>
    <vbox r="@ref(1)">
        <label value="${empty r}" />
        <label value="@load(empty r)" />
    </vbox>
</zk>

returns:

true
false

${} not working with @ref()?


Solution

  • Short answer : no it doesn't.

    First, if you want automatic updates of values use @load(...) because static expressions in ${...} are only evaluated once.

    Second, bind annotations @init/@load are being computed later in the ZK Bind lifecycle than the static EL expressions.

    So ZK first tries and evaluate your ${empty r}, at this time r is not defined so ${empty r} is null. Then later in the lifecycle it'll handle the databinding annotations @.