-
Bug
-
Resolution: Fixed
-
Major
-
8.0.3
-
Security Level: Jimmy
-
None
If a form property is changed programatically the new value is not shown.
In the following example the property city is changed by clicking a button but its new value is not shown.
public class Person { private String firstName; private String lastName; private String city; public Person() { } public Person(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } public String getCity() { return city; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public void setCity(String city) { this.city = city; } public void setFirstName(String firstName) { this.firstName = firstName; } public void setLastName(String lastName) { this.lastName = lastName; } }
public class Test { private final static String[] CITIES = { "Beijing", "Delhi", "Dhaka", "Karachi", "S\u00e3o Paulo", "Shanghai" }; private static String getRandomCity() { return CITIES[(int) (Math.random() * CITIES.length)]; } private Person person; @Command public void doRandomCity(@BindingParam("form") Person form) { if (form != null) { final String old = form.getCity(); String city; do { city = getRandomCity(); } while (city.equals(old)); form.setCity(city); } } @Command @NotifyChange("person") public void doReset() { } @Command @NotifyChange("person") public void doSave() { } public Person getPerson() { return person; } @Init public void init() { person = new Person("John", "Doe"); person.setCity(getRandomCity()); } }
<vlayout viewModel="@id('vm') @init('TestNotify')" form="@id('fx') @load(vm.person) @save(vm.person, before='doSave')"> <hbox widths="5em,16.3em"> <cell align="right"> <label value="First Name" /> </cell> <textbox value="@bind(fx.firstName)" hflex="1" /> </hbox> <hbox widths="5em,16.3em"> <cell align="right"> <label value="Last Name" /> </cell> <textbox value="@bind(fx.lastName)" hflex="1" /> </hbox> <hbox widths="5em,16.3em"> <cell align="right"> <label value="City" /> </cell> <textbox value="@bind(fx.city)" hflex="1" /> </hbox> <hbox widths="7em,7em,7em"> <button label="Random City" onClick="@command('doRandomCity',form=fx)" hflex="1" /> <button label="Reset" onClick="@command('doReset')" disabled="@load(not fxStatus.dirty)" hflex="1" /> <button label="Save" onClick="@command('doSave')" disabled="@load(not fxStatus.dirty)" hflex="1" /> </hbox> </vlayout>