NeilJohnEvans
asked on
AppendItemValue Failing On A Date Type Object When Using Xpages
Hi
I have a complex page where I am trying to submit a date value to the backend document (a text value works) I always end up with a runtime error "[TypeError] Exception occurred calling method NotesDocument.appendItemVa lue(string , java.util.Date) null"
I have dummied up a simple piece of code to show what im doing and where the error is
I must be missing something but I just cant see it.
Oh don't think it make any difference but I'm using 8.5.2 with Extension Library installed
Thanks In Advance
Neil
I have a complex page where I am trying to submit a date value to the backend document (a text value works) I always end up with a runtime error "[TypeError] Exception occurred calling method NotesDocument.appendItemVa
I have dummied up a simple piece of code to show what im doing and where the error is
I must be missing something but I just cant see it.
Oh don't think it make any difference but I'm using 8.5.2 with Extension Library installed
Thanks In Advance
Neil
Unexpected runtime error
The runtime has encountered an unexpected error.
Error source
Page Name:/test.xsp
Control Id: button1
Property: onclick
Exception
Error while executing JavaScript action expression
Script interpreter error, line=7, col=8: [TypeError] Exception occurred calling method NotesDocument.appendItemValue(string, java.util.Date) null
JavaScript code
1: var db:NotesDatabase=database;
2: var fd = requestScope.ff_date.toString()
3: var fdate = new Date(fd);
4: requestScope.ff_date1 = fdate;
5: var rdoc:NotesDocument=db.createDocument();
6: rdoc.appendItemValue("Form","test");
7: rdoc.appendItemValue("test_date",requestScope.ff_date1);
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:button value="Save Date" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript: var db:NotesDatabase=database;
var fd = requestScope.ff_date.toString()
var fdate = new Date(fd);
requestScope.ff_date1 = fdate;
var rdoc:NotesDocument=db.createDocument();
rdoc.appendItemValue("Form","test");
rdoc.appendItemValue("test_date",requestScope.ff_date1);}]]></xp:this.action>
</xp:eventHandler></xp:button>
<xp:br></xp:br>
<xp:inputText id="inputText1" value="#{requestScope.ff_date}">
<xp:dateTimeHelper id="dateTimeHelper1"></xp:dateTimeHelper>
<xp:this.converter>
<xp:convertDateTime type="date" dateStyle="full"></xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
<xp:br></xp:br>
<xp:label value="#{javascript:requestScope.ff_date1}" id="label1"></xp:label></xp:view>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Fantastic Thanks I knew I was missing something, the data type conversions between notes and java are something I don't think i've grasped right yet
After having banged my poor head several times I can only say that I *think* I now understand how it supposed to be done, yet I'm sure I'll get some more bumps on my head... And beware of time zones!!
Secondly: if you want to store a date value in a Notes item, it has to be a NotesDateTime object. You can't use a java.util.Date object.