Issue while using @NotifyChange("*") in zk 8.5.0

asked 2018-11-16 18:59:47 +0800

ShilpaSareen gravatar image ShilpaSareen
3 2

updated 2018-11-19 10:54:36 +0800

cor3000 gravatar image cor3000
4406 2 7
ZK Team

I have upgraded my zk project from zk 7.0.2 to 8.5.0 and I have faced a problem while using

"*" in @NotifyChange. Folliwing is scenario I am facing problem:

I am using combobox and bind a property with selectedItem="@bind(vm.selectedFilter)" and calling a command onChange="@command('filterItems')" and above filterItems command I am using @NotifyChange("*").

<combobox selectedItem="@bind(vm.selectedFilter)"
      value="Show All Items" model="@load(vm.itemCategoriesForSearch)"
  <template name="model">
<comboitem label="${each.name}" />

and VM code is as follows:

public void filterMenuItems()   {
     // code to filter items    

It is creating problem when I selected an item from combobox and it first call setter for selectedFilter() and then command "filterItems" is executed but because of using "*" wildcard in @NotifyChange it is triggering the same event second time but the filters are cleared this time so the output is not as expected.

If anybody face the same problem, or suggestions are welcome.

delete flag offensive retag edit


based on your description it's hard to imagine what's going wrong, can you provide a runnable example on http://zkfiddle.org this will help to illustrate your problem and give us a chance to look at it directly

cor3000 ( 2018-11-19 11:16:13 +0800 )edit

I have posted an example on zk fiddle, here is the link with example: http://zkfiddle.org/sample/4m1jds/29-Issue-while-using-NotifyChange-in-zk-8-5-0 If I use specific property to notify change like: "@NotifyChange("filteredItems")" on my command then it is filtering correctly. Please have a look.

ShilpaSareen ( 2018-11-19 20:22:03 +0800 )edit

I have used @NotifyChange("*") at many places in my project, it is incorrectly calling the setter of selectedFilter twice. and the filters are null in second call. It is a big problem for us.

ShilpaSareen ( 2018-11-19 20:41:59 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-11-20 12:16:31 +0800

cor3000 gravatar image cor3000
4406 2 7
ZK Team

Thanks for the example!

the event order of the onChange and onSelect event changed somewhere between ZK 7/8/8.5 (I don't recall exactly when)

Combobox unfortunately holds redundant state about selection and text value. If you use either consisitently the problem will go away.

e.g use selectedItem with onSelect

<combobox autodrop="true" readonly="true"
          buttonVisible="true" mold="rounded"
          placeholder="Show All Menu Items"

or use (text)value with onChange

<combobox autodrop="true" readonly="true"
          buttonVisible="true" mold="rounded"
          placeholder="Show All Menu Items"

Both cases worked for me.

However when using @NotifyChange("*") you are losing some built in functionalities that make this hassle avoidable in the first place.

I took the freedom to remove the unnecessary code in your example (just for your reference): http://zkfiddle.org/sample/4m1jds/31-Issue-while-using-NotifyChange-in-zk-8-5-0

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

1 follower



Asked: 2018-11-16 18:59:47 +0800

Seen: 6 times

Last updated: Nov 20 '18

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