问题
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:
- RESTORE_VIEW - get server-side map of the page (component tree)
- APPLY_REQUEST_VALUES - push string values entered into browser into components'
submittedValue
property - PROCESS_VALIDATIONS - check
submittedValue
properties can be converted to correct datatype and pass validation - UPDATE_MODEL_VALUES - convert
submittedValue
and write tovalue
property, clearingsubmittedValue
property - INVOKE_APPLICATION - run SSJS
- RENDER_RESPONSE - calculate HTML to output
来源:https://stackoverflow.com/questions/37569705/xpage-datetime-picker-validation-does-not-work-on-date-change