Reputation: 3127
I have a document in Xpages that is managed by an ObjectBean. Binding my fields in the Xpage with EL, so fields look like...
<xp:inputText id="inputText2" xp:key="field"
value="#{ObjectBean.serialNumber}" />
</xp:this.facets>
In my bean I have getters,setters,loading, validation and so on and it works fine.
Now I need to add a date field. In the Xpage I have
<xp:inputText xp:key="field"
id="checkInDate" value="#{ObjectBean.checkInDate}">
<xp:this.converter>
<xp:convertDateTime
type="date">
</xp:convertDateTime>
</xp:this.converter>
<xp:dateTimeHelper>
</xp:dateTimeHelper>
</xp:inputText>
I realize that adding a Date or DateTime field will require some special code, but cannot figure out what to do.
My getters and setters are:
public Date getCheckInDate() {
if (checkInDate == null) {
checkInDate = new Date();
}
return checkInDate;
}
public void setCheckInDate(Date checkInDate) {
this.checkInDate = checkInDate;
}
In my save I am trying this
Date tmpDate = session.createDateTime(checkInDate).toJavaDate(); doc.replaceItemValue("checkInDate",checkInDate);
and this
doc.replaceItemValue("checkInDate",session.createDateTime(checkInDate));
but I either get an error, or in the second case I don't get an error but nothing is saved (the doc is not saved).
Upvotes: 1
Views: 718
Reputation: 1271
You are passing a Date as parameter to the method createDateTime, but in the documentation is stated it should be a String.
You need to convert Date to a String, see http://www.mkyong.com/java/java-date-and-calendar-examples/
Or use OpenNTF Domino API, replaceItemValue will also accept a Date ;-)
Upvotes: 5