-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Let's assume a simple 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. Has anyone an idea why the notification here fails?
Ah, it seems that @NotifyChange does not support child properties like...
@NotifyChanges({"child.elementVisible", "someotherproperty"})
Instead we have to use something like this...
BindUtils.postNotifyChange(null, null, child, "elementVisible");
...which does seem to work. And we have to hope for the other thing as a new feature ;-)
Hello,
I think @NotifyChanges does not support this (child.elementVisible) , instead you should do this : @NotifyChanges({"child", "someotherproperty"})
Asked: 2016-09-15 13:11:18 +0800
Seen: 42 times
Last updated: Sep 30 '16
MVVM Validator: class not found ? [closed]
Conditional evaluation component in mvvm
Children Binding : UiException Callable only in the event listener
Attributes in macro was not updated after notifyChange
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