0

MVVM Binding Properties of Child object - No change notification?

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

FlorianSchaetz gravatar image FlorianSchaetz flag of Germany
31 6

updated 2016-09-15 13:11:47 +0800

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?

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2016-09-15 13:24:04 +0800

FlorianSchaetz gravatar image FlorianSchaetz flag of Germany
31 6

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 ;-)

link publish delete flag offensive edit
0

answered 2016-09-16 07:58:54 +0800

Darksu gravatar image Darksu
1991 1 4

Hello,

There is always the option @NotifyChange("*") but this will update everything.

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2016-09-30 15:07:49 +0800

SoumiaOulkasse gravatar image SoumiaOulkasse
3 1

Hello,

I think @NotifyChanges does not support this (child.elementVisible) , instead you should do this : @NotifyChanges({"child", "someotherproperty"})

link publish delete flag offensive 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

Follow
1 follower

RSS

Stats

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

Seen: 42 times

Last updated: Sep 30 '16

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