Solved

AppendItemValue Failing On A Date Type Object When Using Xpages

Posted on 2011-03-11
4
1,852 Views
Last Modified: 2013-12-18
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.appendItemValue(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

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);

Open in new window

<?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>

Open in new window

0
Comment
Question by:NeilJohnEvans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35109090
Firstly: do you want two or more values in your document, since you use appendItemValue? Or could you use replaceItemValue instead?

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.
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 250 total points
ID: 35109145
Check the NotesDateTime class. Use session.createDateTime(javaDate) to get an object, then pass that as a parameter. Or setLocalTime. Use toJavaDate to convert it to a Java-type Date.
0
 

Author Closing Comment

by:NeilJohnEvans
ID: 35112831
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
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35112989
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!!
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Check ALL SP in database make sure there are no errors 17 71
auto play video on web page 4 59
Exchange OWA website Redirection 7 81
WordPress Page Content Lost 2 50
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question