asked
2014-09-25 05:54:36 +0800
unitcell 28 ● 4 Hi all,
using form binding, the part of code is below,
View:
<div form="@id('fx') @load(vm.personModel) @save(vm.personModel, before='save')">
Name: <textbox value="@load(fx.name)"/>
Date: <datebox value="@save(fx.date)" onCreate="self.setRawValue(new Date())" format="yyyy/MM/dd"/>
</div>
<div>
<button label="save" onClick="@command('save')" />
VM:
public class PersonVM {
private Person person;
public Person getPersonModel() {
if(person == null) {
person = new Person("Water", new Date());
}
return person;
}
@Command
public void save() {
System.out.println(person.getName());
System.out.println(person.getDate());
}
}
If user do not anything, just click save button, it will got person.getDate() is null.
How do I get default date from view end ?
Thanx.