0

notifyChange of setter

asked 2014-12-09 08:08:24 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

updated 2014-12-09 08:09:23 +0800

Hi all,

I want to start a discussion for this fiddle

If you run the fiddle => enter text in first textbox you see the label next to the textbox is sitting itself correct.
This is normal cause I trigger the setter and he notify's the zul because he is changed.

The second textbox is almost the same, I just added an extra notifychange on the setter. Mine expectation : the 2 labels should setting itself correct.
Result : only the label above is setting itself correct.

The third textbox is doing the result what I expected for the second one. The change is that I notify an extra field (itself).

It's strange behaviour in mine oppinion cause why do we need to declare that the field we are setting is getting updated or is it just a good functionality because we don't always have to notify the field we are setting?

I'd like to hear everybody's oppinion about this.

Greetz chill.

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2014-12-09 09:10:56 +0800

cyiannoulis gravatar image cyiannoulis
1191 10

I agree with you that sometimes the binding mechanism is not very elegant but it is flexible. On the other hand, why did you use the @NotifyChange instead of the @DependsOn? Something like this looks more sensible to me:

public class TestVM {
  private String remark;
  public String getRemark() {
    return remark;
  }
  public void setRemark(String remark) {
    this.remark = remark;
  }
  @DependsOn("remark")
  public String getRemark2() {
    return remark;
  }  
  public void setRemark2(String remark) {
    this.remark = remark;
  }
  @DependsOn("remark")
  public String getRemark3() {
    return remark;
  }  
  public void setRemark3(String remark) {
    this.remark = remark;
  }
}

Costas

link publish delete flag offensive edit

answered 2014-12-09 10:23:24 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

Hey Costas,

I'm not (for the moment) a real fan of the DependsOn and find mixing the 2 is asking for faults to happen.
Your comment is indeed correct that it will work correctly when you use the DependsOn, maybe I need to revise mine oppinion about the DependsOn.

Greetz chill.

link publish delete flag offensive edit
Your reply
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: 2014-12-09 08:08:24 +0800

Seen: 11 times

Last updated: Dec 09 '14

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