-
FEATURED COMPONENTS
First time here? Check out the FAQ!
1 | initial version | |
Let's assume a simple vm...
<div width="100%" height="100%" viewModel="@id('vm') @init('com.example.MyVM')">
<div visible="@load(vm.child.isElementVisible)"/>
<div visible="@load(not vm.child.isElementVisible)"/>
<button onClick="@command('doSomething')"/>
</div>
Now I've got a simple comand in the VM...
@Command
@NotifyChanges({"child.elementVisible", "someotherproperty"})
public void doSomething() {
this.child.setElementVisible( !this.child.isElementVisible() );
}
Unfortunately, this doesn't work at all. The visibilty doesn't change. As the initial value of the visibility works fine, it seems that only the change notification doesn't seem to work.
But if I add a delegate method to the vm itself...
public boolean isElementVisible() {
return this.child.isElementVisible();
}
...and use that in my zul...
<div visible="@load(vm.isElementVisible)"/>
<div visible="@load(not vm.isElementVisible)"/>
...it works perfectly fine.
2 | No.2 Revision |
Let's assume a simple vm...zul...
<div width="100%" height="100%" viewModel="@id('vm') @init('com.example.MyVM')">
<div visible="@load(vm.child.isElementVisible)"/>
<div visible="@load(not vm.child.isElementVisible)"/>
<button onClick="@command('doSomething')"/>
</div>
Now I've got a simple comand in the VM...
@Command
@NotifyChanges({"child.elementVisible", "someotherproperty"})
public void doSomething() {
this.child.setElementVisible( !this.child.isElementVisible() );
}
Unfortunately, this doesn't work at all. The visibilty doesn't change. As the initial value of the visibility works fine, it seems that only the change notification doesn't seem to work.
But if I add a delegate method to the vm itself...
public boolean isElementVisible() {
return this.child.isElementVisible();
}
...and use that in my zul...
<div visible="@load(vm.isElementVisible)"/>
<div visible="@load(not vm.isElementVisible)"/>
...it works perfectly fine.fine. Has anyone an idea why the notification here fails?