Subject: Solved!
My solution was to forget about the built in date picker widget, and use one straight from Dojo.
I added a regular edit box, bound to the requestScope variable ‘Date’:
<xp:inputText id=“DatePicker” value=“#{requestScope.Date}” defaultValue=“#{javascript:@Today()}”>
</xp:inputText>
Then, below that I added an ‘output script’ which creates the Dojo DateTextBox widget using various dynamic variables:
var myvalue = "#{javascript:
var value;
if(requestScope.Date == null) {
value = session.createDateTime(“Today”);
} else {
value = session.createDateTime(requestScope.Date);
}
return value.toJavaDate();
}";
var tmpStartDate = "#{javascript:
var today = session.createDateTime(“Today”);
today.adjustMonth(-1)
return today.toJavaDate()
;}";
var tmpEndDate = "#{javascript:
var today = session.createDateTime(“Today”);
today.adjustMonth(18)
return today.toJavaDate()
;}";
var newStartDate = new Date(tmpStartDate);
var newEndDate = new Date(tmpEndDate);
var pickedDate = new Date(myvalue);
new dijit.form.DateTextBox({name:“#{id:DatePicker}”,value:pickedDate, constraints:{datePattern:‘MMM d, yyyy’,timePattern:‘h:mm:ss a’,selector:‘date’, min: newStartDate, max: newEndDate}},
XSP.getElementById(“#{id:DatePicker}”));
Finally, I needed to add a ‘dojoModule’ resource to the XPage properties, with ‘dijit.form.DateTextBox’ as the name.
When I open the page, my edit box has been replaced with the date picker, and all the dates outside my range are greyed out. The only issue is that the field doesn’t have the nice calendar icon next to it, like the default one. I’m assuming that is a CSS issue of some sort.
Karl