-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have a zul page in which I use zkbind to bind values to the components. Now I encounter an issue with a separate @load and @save configuration. As seen below, the datebox is initialised with either the current date or the value of the date field. However, If I save the currentDocument using a @Command, the currentDate is not set in the document. Apparently the @save is only triggered by a change in the datebox, not because the value set in the @load.
<datebox value="@load(salesorder_vm.currentDocument.date eq null ? c:new('java.util.Date'): salesorder_vm.currentDocument.date) @save(salesorder_vm.currentDocument.date)"/>
Is there any pattern or trigger I can use to make zkbind see the @load as a change of the currentdocument?
@Command
public void initialValue(){}
<datebox value="@load(salesorder_vm.currentDocument.date eq null ? c:new('java.util.Date'): salesorder_vm.currentDocument.date) @save(salesorder_vm.currentDocument.date) @save(salesorder_vm.currentDocument.date, after='initialValue')" onCreate="@command('initialValue')"/>
If you don't want so much in the zul, you just could do (I prefer this one) :
<datebox value="@bind(salesorder_vm.currentDocument.date onCreate="@command('initialValue', currentDoc = salesorder_vm.currentDocument)"/>
@Command
public void initialValue(@BindingParam("currentDoc") Document doc){
if (doc.getDate() == null) {
doc.setDate(new Date());
BindUtils.postNotifyChange(null,null,doc,"date");
}
}
Greetz chill.
Asked: 2015-03-12 19:21:24 +0800
Seen: 18 times
Last updated: Mar 14 '15