0

Date is not updating

asked 2014-08-18 10:34:56 +0800

imranmali gravatar image imranmali
1

updated 2014-09-04 11:25:11 +0800

sitansu gravatar image sitansu
2254 13
http://java91.blogspot.in...

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.

delete flag offensive retag edit

Comments

@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 )edit

i was trying to do this but i have crashes all the time

sellyn ( 2014-09-04 11:21:45 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-08-23 18:40:24 +0800

Darksu gravatar image Darksu
1991 1 4

Hello imranmali,

From a quick look at your code you declare the datebox dtDOB1 as final. Meaning you will not be able to update it's value.

Best Regards,

Darksu

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2014-08-18 10:34:56 +0800

Seen: 22 times

Last updated: Sep 04 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More