xPage dateTime picker validation does not work on date change

微笑、不失礼 提交于 2019-12-11 05:01:05

问题


Here is my datePicker control where expression validation works fine:

<xp:inputText id="inputComboUntil">
    <xp:this.converter><xp:convertDateTime pattern="MMM d, yyyy"></xp:convertDateTime></xp:this.converter>
    <xp:this.validators>
        <xp:validateExpression>
            <xp:this.expression><![CDATA[#{javascript:var var1 = getComponent("inputDate").getValue();
                if(var1!=null){
                    var var1D:NotesDateTime = session.createDateTime(var1);
                    var var2D:NotesDateTime = session.createDateTime("Today");  
                    var2D.setNow();

                    if(var1D.timeDifference(var2D) < 0){ 
                        return false;
                    } else {
                        return true;
                    }
                } else {
                    return true;
                }}]]>
            </xp:this.expression>
            <xp:this.message><![CDATA[You cannot set date in the past]]></xp:this.message>
        </xp:validateExpression>
    </xp:this.validators>
    <xp:dateTimeHelper id="dateTimeHelper3"></xp:dateTimeHelper>
</xp:inputText>

But if I pick another correct date it seems the validation works with the old one so then fails with validation error. I have nothing in onChange event. Assume picking new date should refresh validation. Note: I have this problem on Domino 8.5.3


回答1:


Try getSubmittedValue() instead, but note the value will be a String, not a Date.

Basic partial refresh lifecycle is:

  1. RESTORE_VIEW - get server-side map of the page (component tree)
  2. APPLY_REQUEST_VALUES - push string values entered into browser into components' submittedValue property
  3. PROCESS_VALIDATIONS - check submittedValue properties can be converted to correct datatype and pass validation
  4. UPDATE_MODEL_VALUES - convert submittedValue and write to value property, clearing submittedValue property
  5. INVOKE_APPLICATION - run SSJS
  6. RENDER_RESPONSE - calculate HTML to output


来源:https://stackoverflow.com/questions/37569705/xpage-datetime-picker-validation-does-not-work-on-date-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!