-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all,
I have a problem with databinding if I modify the value of a dateBox on an onChangeEvent :
zul file :
<textbox onChange="@command('onAgeChange', age=event.value, dob=dtbxDOB)"/>
<datebox id="dtbxDOB" value="@bind(fx.dob)" />
VM :
@Command
@NotifyChange("dob")
public void onAgeChange( @BindingParam("age") String strAge_P
,@BindingParam("dob") Datebox dtbxDOB_P){
Calendar cal = Calendar.getInstance();
Integer iCurrentYear = cal.get(Calendar.YEAR);
Integer iAge = Integer.valueOf(strAge_P);
Integer iDOBYear = iCurrentYear - iAge;
Calendar calDOB = Calendar.getInstance();
calDOB.set(Calendar.YEAR, iDOBYear);
calDOB.set(Calendar.DAY_OF_MONTH, 1);
calDOB.set(Calendar.MONTH, 0);
dtbxDOB_P.setValue(calDOB.getTime());
}
The purpose is to set the date if the user enter the age, but the problem is that the modified date is not bound. Is anyone has an idea please ?
Sorry for my english. Many Thanks !
Hello,
there is just a little mistyping...
<textbox onchange="@command('onAgeChange', age=event.value, dob=dtbxDOB)"/>
"onchange" should be "onChange
"
A suggestion is:
Don't need to pass datebox as parameter when you're using @bind with datebox. It will update automatically when you change "dob" because you have @NotifyChange
In design concept, ViewModel is independent to UI Component.
Hello,
Thanks for your response, but in my question there is no "onchange" in my zul file but "onChange". In fact, i need to set the datebox's value with the textbox's input representing the age (old?) of the user. In example if the user set "20" in the textbox, the value of the date box is automatically set with 01/01/1993. This is working well with the onChange event but after the form cannot be validated because the Dob is mandatory.
Very sorry for my english and many thanks for your help !
Hi yohann,
You can pass fx variable to the command
<textbox onChange="@command('onAgeChange', age=self.value, fx=fx)"/>
the call notify change in your command
@Command
public void onAgeChange( @BindingParam("age") String strAge_P, @BindingParam("fx") Form fx) {
BindUtils.postNotifyChange(null, null, fx, "dob");
Asked: 2013-09-06 16:02:58 +0800
Seen: 104 times
Last updated: Sep 23 '13
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]