@NotifyChange"
m (replace tt with code (via JWB)) |
m ((via JWB)) |
||
(One intermediate revision by the same user not shown) | |||
Line 22: | Line 22: | ||
'''Purpose:''' To notify binder one or more properties change. | '''Purpose:''' To notify binder one or more properties change. | ||
− | By default, a property set by binder through setter method will notify this property changed without this annotation. You could use this annotation on setter method to override default notification target. You could also add this annotation on a command method to notify properties that are changed after command execution. To avoid the default notification, use <code> @NotifyChangeDisabled </code> on setter method solely. Giving "*" in annotation element means notify all properties in a ViewModel. | + | By default, a property set by binder through setter method will notify this property changed without this annotation. You could use this annotation on setter method to override default notification target. You could also add this annotation on a command method to notify properties that are changed after command execution. To avoid the default notification, use <code>@NotifyChangeDisabled</code> on setter method solely. Giving "*" in annotation element means notify all properties in a ViewModel. |
Use "." to enforce reloading the instance of the class in where the annotation locates, not an instance's property. | Use "." to enforce reloading the instance of the class in where the annotation locates, not an instance's property. | ||
Line 54: | Line 54: | ||
=Version History= | =Version History= | ||
− | + | ||
{| class='wikitable' | width="100%" | {| class='wikitable' | width="100%" | ||
! Version !! Date !! Content | ! Version !! Date !! Content |
Latest revision as of 07:36, 8 July 2022
This article is out of date, please refer to zk-mvvm-book/8.0/syntax/viewmodel/notifychange for more up to date information.
Syntax
@NotifyChange("anotherProperty")
@NotifyChange({"secondProperty","thirdProperty"})
@NotifyChange("*")
@NotifyChange(".")
Description
Target: method (setter or command method)
Purpose: To notify binder one or more properties change.
By default, a property set by binder through setter method will notify this property changed without this annotation. You could use this annotation on setter method to override default notification target. You could also add this annotation on a command method to notify properties that are changed after command execution. To avoid the default notification, use @NotifyChangeDisabled
on setter method solely. Giving "*" in annotation element means notify all properties in a ViewModel.
Use "." to enforce reloading the instance of the class in where the annotation locates, not an instance's property.
Example
public class OrderVM {
//other code...
@NotifyChange({"selected","messages"})
public void setSelected(Order selected) {
this.selected = selected;
}
//action command
@NotifyChange({"selected","orders","messages"})
@Command
public void newOrder(){
Order order = new Order();
getOrders().add(order); //add new order to order list
selected = order;//select the new one
}
}
Version History
Version | Date | Content |
---|---|---|
6.0.0 | February 2012 | The MVVM was introduced. |