@Retention(value=SOURCE) @Target(value=METHOD) public @interface OnPropertyChange
Model
has been changed. This is
especially useful when one wants to react to changes in the
model caused by the rendered view. In case of
knockout.js technology
one could for example react to selection of a name from a combo
box:
<!-- associates the selected value with property name --> <select data-bind="value: name"> <option>Jiří</option> <option>Jarda</option> <option>Petr</option> <option>Tomáš</option> </select> // Java code snippet reacting to change of the name property:The method's first argument should be the instance of the associated@OnPropertyChange
("name") static void propertyChanged(AModel inst,String
propertyName) { // schedule some operation // on the model }
model class
. The method shall be non-private
and unless instance mode
is on also static.
There can be an optional second String
argument which will be set
to the name of the changed property. The second argument is only useful when
a single method reacts to changes in multiple properties.
An online example using this technique is
available here -
it observes selection in a combo box and in case it changes
the example sends a network
request and asynchronously updates
list of code snippets.
public abstract String[] value
Copyright © 2018 NetBeans. All rights reserved.