1

We are using @Command method for firing any method but we are using @NotifyChange method for reflecting the class variables. But In place of @NotifyChange we use

BindUtils.postNotifyChange(null, null, this.class, "*");

So which statement is good for better performance.

jaideep
  • 1,631
  • 17
  • 19
  • duplicate here :http://forum.zkoss.org/question/91652/which-one-is-good-for-better-performance/ – Sitansu Mar 14 '14 at 07:32

2 Answers2

4

Actually, BindUtils can be more powerfull then @NotifyChanged If you are gonna use it in the same way I don't think there is a big performance difference. The only big difference is that @NotifyChange only works on setters and commands and that BindUtils can be called from each method.

Now, when will there a difference?
Assume you have a list what you get with this :

public List<User> getUsers() {
    return users;
}

Assume that we have buttons next to each user and the button fires a command that changes that user (like blocking that user) What we can do is put the @notifyChanged("users") what will mean in zk asking getUsers();

If we use BindUtils we can do the following :

BindUtils.postNotifyChanged(null,null,user,"*");

or

BindUtils.postNotifyCHanged(null,null,user,"blocked");

Even we don't have a getter for that user in our VM this will still be executed and only that user in the whole list will update. With the first command all data is refreshed, with the second only the blocked is updated. Now the second isn't always possible cause maybe you don't know what field or all fields are updated but still you update 1 user in stead of getting all x users.

chillworld
  • 4,207
  • 3
  • 23
  • 50
0

Before I put this question in SO look at here:

Is it possible use @NotifyChange instead of BindUtils.postNotifyChange?

I personally suggest to use specific variable instead of "*" And its not better performancewise BindUtils.postNotifyChange(null, null, this.class, "*");

The basic difference beetween BindUtils and @NotifyChange :

BindUtils just takes a single property and @NotifyChange takes multiple property at a time.

Community
  • 1
  • 1
Sitansu
  • 3,225
  • 8
  • 34
  • 61