Revision history [back]

click to hide/show revision 1
initial version

asked 2016-09-15 13:11:18 +0800

FlorianSchaetz gravatar image FlorianSchaetz flag of Germany

MVVM Binding Properties of Child object - No change notification?

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.

MVVM Binding Properties of Child object - No change notification?

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?

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