Issue 31888  —   Datepicker (DSP) onchange event fired with every keypress

Status:   Planned for resolution in 9.7.05

Solution available in patch(es):      10.3.02.008    9.7.05.021

Description:

 Summary:
 Datepicker (DSP) onchange event fired with every keypress

  Environment:
  +Uniface Version  : 10.3
  +Operating System : OS independent
  +Database         : DBMS independent
  +Browsers         : Browser independent

 Reproduction:
 ------------

 1)      Import testdate.xml
           containing DSP TESTDATE and entity D_DATETIME
 2)      Compile DSP TESTDATE and the model D_DATETIME
 3)      Start the DSP TESTDATE in a browser
 4)      Click on button retrieve and set the focus on field DATE1
 5)       Use tab to enter field DATE2 (red)
 6)       put the focus on day                    -> dd/mm/yyyy      use
 keyboard to enter  Digit between 0-9
 7)       tab or click to put the focus on  month -> dd/mm/yyyy      use
 keyboard to enter  Digit between 0-9
 8)       tab or click to put the focus on  Year  -> dd/mm/yyyy      use
 keyboard to enter  Digit between 0-9

 Actual result:
 ----------------------------------
 When adding a digit to the field using the keyboard, the onchange event is
 fired.

 Expected result:
 ---------------
 Should be able to enter a full date, without onchange firing on each key press.

Workaround:

 The OnChange trigger firing for the datepicker when using the small arrow is
 correct:
 The value is changed.
 One can never know in front whether an user will use this arrow 1,2,3 or more
 times:
 How can one know whether an user is finished editing the date ?
 If the OnChange would not fire this would be a bug.
 
 Checking on the server is sometimes needed.
 It is however not a good idea/design to activate this check via the OnChange
 trigger for the datepicker.
 The validation should be on a moment the user is finished editing.
 A validate statement can be programmed.
 
 The OnBlur trigger can also activate serverside processing that activates this
 service.
 OnChange in this case is too early because one does not know if the user has
 finished changing the date.
 Two remarks:
 Server receives YYYY-MM-DD
 To calculate we need YYYYMMDD
 To send to the client we need again YYYY-MM-DD
 
 
 The JS in webtrigger onBlur can be reduced to something like:
 javascript
     // this is a uniface.Field object
     this.getInstance().activate("CONVERT_DATE", this.getValue())
     .then(function(p) {
           this.setValue(p.args[0]);  // when using inout
 //          this.setValue(p.args[1]); // when using out
        }
     ).catch(function(e) { alert(e); });
 endjavascript
 
 operation convert_date
 public web
 scope
 endscope
 params
             string d1: inout
 endparams
 variables
 date vd1
 string vyear,vmonth,vday
 endvariables
 vd1=$replace(d1,1,"-","",-1)
 vd1 = vd1 + 2d
 d1=vd1
 vyear=d1[1:4]
 vmonth=d1[5:2]
 vday=d1[7:2]
 d1=$concat(vyear,"-",vmonth,"-",vday)
 end

Notes: