-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I've created a datebox in popup. When button is click the popup will appear the datebox is creating dynamically. My scenario is change the value of datebox in popup when the value of another an other date change (i.e: onblur of date event in form). The date is appearing for the first time but its not changing for the second time. Kindly help i'm stuck on this. I'm using zk 5.0.6 version
Here is the code:
final Datebox dtDOB1 = new Datebox();
setMandatConstraints(dtDOB1,returnNoEmptyCons("Date
Of Birth"));//Setting contraint
setIdForComponent(dtDOB1,"dob"+partialId);//Setting
Id
dtDOB1.setFormat(DateUtil.DEFAULT_DATE_FORMAT);//Setting
format //on blur Event
dtDOB1.addEventListener(Events.ON_BLUR,
new EventListener() {
public void onEvent(Event event) throws Exception {
Datebox db = (Datebox)event.getTarget(); //
.setValue(Integer.parseInt(getAge(DateUtil.toString(dobins.getValue(),"dd/MMM/yyyy"),
DateUtil.toString(dateDepart.getValue(),"dd/MMM/yyyy"))));
Intbox ab = (Intbox)db.getNextSibling().getNextSibling().getNextSibling().getNextSibling();
// calculateAge(db,ab);
if(db.getValue()!= null && !db.getValue().equals(""))
ab.setValue(Integer.parseInt(getAge(DateUtil.toString(db.getValue(),DateUtil.DEFAULT_DATE_FORMAT),
DateUtil.toString(dateDepart.getValue(),DateUtil.DEFAULT_DATE_FORMAT))));
//members age not equal and greater to 80 years as at date
departure
if(db.getId().contains("Adult")){
if(ab.getValue() != null){
if(ab.getValue() >= 80){
errorLabel.setVisible(true);
errorLabel.setValue(adultDateError);
}
else if(ab.getValue() >= 70 && ab.getValue() < 80 ){
errorLabel.setValue("It requires an approval from Head Office
of LOLC Insurance Co Ltd.");
errorLabel.setVisible(true);
}
else
errorLabel.setVisible(false);
}
else
errorLabel.setVisible(false);
}
//children aged should not be below 180 days and 18 years and above
as at date departure from sri lanka -
if(db.getId().contains("Child")){
if(ab.getValue() != null){
if(DateUtil.getDifferenceMonths(db.getValue(),
dateDepart.getValue()) < 6 ||
DateUtil.getDifferenceYears(db.getValue(),
dateDepart.getValue()) >= 18 ){
errorLabel.setVisible(true);
errorLabel.setValue(childDateError);
}
else
errorLabel.setVisible(false);
}
else
errorLabel.setVisible(false);
}
}
});
dtDOB1.setValue(dobins.getValue());
dtDOB1.setText(dobins.getText());
Thanks.
Asked: 2014-08-18 10:34:56 +0800
Seen: 22 times
Last updated: Sep 04 '14
@Darksu thanks for ur answer. I made final dtDOB1 to access inside eventListener. I manage to resolve as the problem is in another logic. Thanks again for ur answer.
imranmali ( 2014-09-03 04:46:41 +0800 )editi was trying to do this but i have crashes all the time
sellyn ( 2014-09-04 11:21:45 +0800 )edit