@DependsOn"
From Documentation
Tmillsclare (talk | contribs) m (→Description) |
m ((via JWB)) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{ZKDevelopersReferencePageHeader}} | {{ZKDevelopersReferencePageHeader}} | ||
+ | {{Deprecated | url=[http://books.zkoss.org/zk-mvvm-book/8.0/syntax/dependson.html zk-mvvm-book/8.0/syntax/viewmodel/dependson]|}} | ||
+ | |||
=Syntax= | =Syntax= | ||
Line 11: | Line 13: | ||
'''Purpose:''' To notify change upon property's dependency. | '''Purpose:''' To notify change upon property's dependency. | ||
− | It has the same function as < | + | It has the same function as <code>@NotifyChange</code> but inverse meaning. It's used to notify binder that getter method's target property is changed because one or more properties it depends on are changed. It can eliminate distributed <code>@NotifyChange</code> annotations in a ViewModel when a calculated property depends on multiple properties. |
= Example = | = Example = | ||
Line 47: | Line 49: | ||
=Version History= | =Version History= | ||
− | + | ||
− | {| | + | {| class='wikitable' | width="100%" |
! Version !! Date !! Content | ! Version !! Date !! Content | ||
|- | |- |
Latest revision as of 07:35, 8 July 2022
This article is out of date, please refer to zk-mvvm-book/8.0/syntax/viewmodel/dependson for more up to date information.
Syntax
@DependsOn
Description
Target: getter method
Purpose: To notify change upon property's dependency.
It has the same function as @NotifyChange
but inverse meaning. It's used to notify binder that getter method's target property is changed because one or more properties it depends on are changed. It can eliminate distributed @NotifyChange
annotations in a ViewModel when a calculated property depends on multiple properties.
Example
public class FullnameViewModel{
private String firstname;
private String lastname;
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
@DependsOn({"firstname", "lastname"})
public String getFullname() {
return (firstname == null ? "" : firstname) + " "
+ (lastname == null ? "" : lastname);
}
}
Version History
Version | Date | Content |
---|---|---|
6.0.0 | February 2012 | The MVVM was introduced. |