ListModelList notifyChange

asked 2021-09-29 16:06:03 +0800

aUser gravatar image aUser
137 1 4


suppose I have this .zul file:

    <grid model="@load(vm.names)" visible="@load(not empty vm.names)">
            <column label="Name" align="center" />
        <template name="model" var="name">
                <label value="@load(name)" />

    <button label="Update names" onClick="@command('updateNames')" />

In the VM, i have something like this:

private List<String> names = new ListModelList<String>();
public void updateNames() {

public List<String> getNames() {
    return names;

I wanted the grid in the .zul page to be visibile only when the model was not empty but this doesn't work. In this scenario, the grid is never visible. To make it visible/invisible based on the data of the model, I have to post a NotifyChange (either by BindUtils.postNotifyChange(...) or @NotifyChange annotation).

It's kinda annoying because I want to use the ListModelList implementation to not send notifications. Of course, if I remove the visible property of the grid, for the sake of clarity like this:

<grid model="@load(vm.names)">

the grid is updated each time the number of rows changes.

Can I do something to not send a NotifyChange in order to make the grid visible only when the model contains rows?

Thank you

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-09-30 10:55:52 +0800

cor3000 gravatar image cor3000
6280 2 7

Not really, since the expression vm.names doesn't change when the contents change the load binding will not evaluate automatically.

However you can make the load binding evaluate conditionally based on command e.g. your updateNames-command.

visible="@load(not empty vm.names, after='updateNames')"

Maybe that's good enough for your scenario.

link publish delete flag offensive edit


Thank you, that is enough for what I have to do

aUser ( 2021-10-01 16:06:13 +0800 )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: 2021-09-29 16:06:03 +0800

Seen: 7 times

Last updated: Sep 30 '21

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