Reputation: 697
On an xpage I have an inputtext control:
<xp:inputText
value="#{employeeBean.employee.dateOfEmployment}">
<xp:this.defaultValue><![CDATA[#{javascript:var dt:NotesDateTime = session.createDateTime("Today");
dt.adjustMonth(-6);
return dt.getDateOnly();}]]></xp:this.defaultValue>
<xp:this.converter>
<xp:convertDateTime type="date"></xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
The value can be e.g.: 2016-10-06
When I want to save my object I get the following message for this field:
This field is not a valid date
Can anybody tell me what can be the cause of this and how I should correct my code?
Upvotes: 0
Views: 340
Reputation: 3757
The getDateOnly()
function returns the date part of the NotesDateTime
as a string, but for an xp:inputText
that needs to store a date you need to work with a java.util.Date
. Try this format:
@Adjust( @Now(), 0, -6, 0, 0, 0,0);
You will probably notice that the format of the returned date is different in the input field, but that's format the input control/ server will interpret as a date. If you need a different format, you can always change the converter into something like this:
<xp:this.converter>
<xp:convertDateTime pattern="dd-MM-yyyy"></xp:convertDateTime>
</xp:this.converter>
Upvotes: 1