Ok, work! This is the solution that i was looking! Thank You!
pasqualeleone ( 2014-03-11 15:30:48 +0800 )edit-
FEATURED COMPONENTS
First time here? Check out the FAQ!
hi guys, this is a section of code that causes me problems.
zul file
<button id="btnPrevMonth"
image="/image/common/prev.png"
tooltiptext="${labels.prjSys.timecard.button.prevmont}"
onClick="@command('monthPrev')"
disabled="@load(not objVM.isEmployeeSelected)"/>
<datebox id="dteMonth"
width="80px"
disabled="@load(not objVM.isEmployeeSelected)"
format="${labels.dateMMMyyyyFormat}"
value="@bind(objVM.selectedMonthYear)"
/>
java file
@Command("monthPrev")
@NotifyChange("selectedMonthYear")
public void monthPrev(){
if(selectedMonthYear != null){
Calendar tmp = Calendar.getInstance();
tmp.setTime(selectedMonthYear);
tmp.add(Calendar.MONTH, -1);
this.selectedMonthYear.setTime(tmp.getTimeInMillis());
}
}
As you can see the value of datebox that has a bind on the Date object selectedMonthYear is not updated, although there is the @NotifyChange. I wonder if this is a bug or I'm wrong some instruction.
The Date object was caught by Datebox as it's value member field, since you change Date object's inside TimeInMillis directly, when binder set the value back, Datebox checked it's the same object and didn't update it to client.
change you code from selectedMonthYear.setTime(tmp.getTimeInMillis());
to selectedMonthYear = tmp.getTime();
could avoid this.
Ok, work! This is the solution that i was looking! Thank You!
pasqualeleone ( 2014-03-11 15:30:48 +0800 )editJust Try it :
@Command("monthPrev")
@NotifyChange("selectedMonthYear")
public void monthPrev(){
if(selectedMonthYear != null){
Calendar tmp = Calendar.getInstance();
tmp.setTime(selectedMonthYear);
tmp.add(Calendar.MONTH, -1);
this.selectedMonthYear.setTime(tmp.getTimeInMillis());
BindUtils.postNotifyChange(null, null, VM.this, "selectedMonthYear");
}
}
Asked: 2014-03-10 15:49:13 +0800
Seen: 26 times
Last updated: Mar 11 '14
Problem binding values to a composite component
How to access static member field of a class in zul without zscript
How can i load a constant in .zul
MVVM Validator: class not found ? [closed]
MVVM tab box - delay @load until tab pane displayed?
mvvm, load or save with after or before for seach command
how to fire an event when a variable value loaded through VM
is there any event trigger from zk component on binding ?
ZK team plans to dispose of Composer EventQueues no longer in scope? [closed]