0

@NotifyChange("vm.bean.anotherBean.property") is not working

asked 2013-06-26 15:00:12 +0800

cyiannoulis gravatar image cyiannoulis
1191 10

Maybe i don't know how to do it but it seems strange to me. I have, lets say, a textbox with the following binding:

<textbox value"@load(vm.store.shoppingCart.itemsCount)" />

As soon as i open the page everything works fine and the textbox displays the correct number of items in the cart. Now, if i modify the ShoppingCart's contents the @NotifyChange does not reflect the changes back to the page:

@Command("add-item")
@NotifyChange("store.shoppingCart.itemsCount")
public void addItem(Item item) {
    store.shoppingCart.addItem(item);
}

What am i doing wrong? The only solution i found was to add the 'dummy' getter getCartItemsCount() directly into the ViewModel and bind the textbox to this getter:

value="@load(vm.getCartItemsCount)"

Another way is to make a @NotifyChange(".") but this is to 'heavy' for my page. Is there any other way so that the @NotifyChange mechanism can resolve the properties path?

[ZK ver 6.5.2]

Thank you all /costas

delete flag offensive retag edit

Comments

I had the same problem. But just to close, i used @NotifyChange(".") .

Senthilchettyin ( 2013-06-26 15:18:30 +0800 )edit

@benbai Yes. @NotifyChange("store") worked..

thanks a lot

/costas

cyiannoulis ( 2013-06-28 13:02:18 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-06-27 09:58:21 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

updated 2013-06-27 09:58:47 +0800

Currently VM will not "Chain" the getters,

the code

@NotifyChange("store.shoppingCart.itemsCount")

probably mapped to

public ??? getStore.shoppingCart.itemsCount () // just guess, not sure

change the NotifyChange as below then it should work:

@NotifyChange("store") // vm.getStore()
link publish delete flag offensive edit
1

answered 2013-06-27 12:01:30 +0800

nsharma gravatar image nsharma flag of India
917 1 11

updated 2013-06-27 12:05:22 +0800

Acc. to my understanding,itemscount is a variable in your shoppingCart bean object.you are calling some method to add a item,that doesn't change the itemscount. You have to elaborate a more for better understanding.still try using:-

BindUtils.postNotifyChange(null, null, this.store.shoppingCart, "*");

inside add item method.

link publish delete flag offensive edit

Comments

this should never work,please check postNotifyChange() method again and also check @benbai answer.

sjoshi ( 2013-06-27 12:51:52 +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

Follow
1 follower

RSS

Stats

Asked: 2013-06-26 15:00:12 +0800

Seen: 83 times

Last updated: Jun 28 '13

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