Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Start Date and End Date Validations in Detail block

Narendra EnamalaAug 24 2017 — edited Aug 28 2017

Hi All,

  I have requirement to validate two date input fields at detail block(table-panel collection) as below screen shot. If entered wrong data it thorws error. After error message I got, I am keeping the cursor at second row in the detial block. Then it allows to save. How to restrict wrong date data in detail block. where as at header block it is working fine.

I written code at Backing bean of a page.

public void End\_date\_ch(ValueChangeEvent valueChangeEvent){

  //  System.out.println("End Date-value change event fired"+this.getId1());

          RichInputDate v\_st\_dt=this.getId1();

          RichInputDate v\_end\_dt=this.getId2();

   // System.out.println("start date: "+v\_st\_dt.getValue());

           oracle.jbo.domain.Date v\_st\_dt\_val= (oracle.jbo.domain.Date)v\_st\_dt.getValue();

           oracle.jbo.domain.Date v\_end\_dt\_val= (oracle.jbo.domain.Date)v\_end\_dt.getValue();

           oracle.jbo.domain.Date cur\_dt=(oracle.jbo.domain.Date)new oracle.jbo.domain.Date().getCurrentDate();

                 // System.out.println("current dt============"+cur\_dt);

           if(v\_st\_dt\_val==null) {

                      v\_st\_dt.setValue(cur\_dt);

                     // v\_quot\_dt.resetValue();

                      AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();

                      adfFacesContext.addPartialTarget(v\_st\_dt);

           }else{

            //   System.out.println("Else part entered");

               if(cur\_dt!=null)

                          {

                          if(((v\_st\_dt\_val.dateValue()).after(cur\_dt.dateValue()))) {

                              this.errmsg("Start Date Cannot Be Future Date!", v\_st\_dt.getClientId());

                          }

                          }

               if(v\_st\_dt\_val!=null)

                           {

                    System.out.println("start date validation enters");

                           if(((v\_st\_dt\_val.dateValue()).after(v\_end\_dt\_val.dateValue()))) {

                               this.errmsg("Start Date Should Be Less Than End Date!", v\_end\_dt.getClientId());

                           }

                           }

              if(v\_end\_dt\_val!=null)

                          {

                   System.out.println("End date validation enters");

                          if(((v\_end\_dt\_val.dateValue()).before(v\_st\_dt\_val.dateValue()))) {

                              this.errmsg("End Date Should Be Greater Than Start Date!", v\_end\_dt.getClientId());

                          }

                          }

           }

}

Regards

Naren

datevalidator.jpg

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 25 2017
Added on Aug 24 2017
3 comments
542 views