1
votes

I seem to be losing the value of sessionScope variables between XPages when I load DateTime values from a Notes document (not from the XPage). Here is what I do:

I have an EditBox where the contents are set to type Date only:

<xp:inputText value="#{document1.datum}" id="datum" defaultValue="#{javascript:@Now()}" required="true">
<xp:this.converter>
     <xp:convertDateTime type="date"></xp:convertDateTime>
</xp:this.converter>
<xp:dateTimeHelper></xp:dateTimeHelper>
</xp:inputText>

I then save this to a sessionScope variable :

sessionScope.put ("datum", getComponent("datum").getValue());

Then I change XPages by doing a:

var extCont = facesContext.getExternalContext();
extCont.redirect("xpNextPage.xsp")

I then do a sessionScope.get:

print (sessionScope.get ("datum"));

And the contents are fine.

if I do the same thing with a document that I have loaded:

var date:NotesDateTime = doc.getItemValueDateTimeArray("datum");
var start:NotesDateTime = doc.getItemValueDateTimeArray("von");
var dt:NotesDateTime = session.createDateTime (date [0].getDateOnly() + " " + start [0].getTimeOnly());
sessionScope.put ("datum", dt);

then switch to the next page and try and load it with:

print (sessionScope.get ("datum"));

I get a value null.

I have attached a screenshot of the problem (I printed other fields as well so you can see it is only the DateTime fields that are the problem). I do notice that the format of the DateTime value is different... could this be the problem?

example of the sessionScope variable problem

1
Can you try storing them as Java Dates to the sessionScope (e.g. ndt.toJavaDate() ) instead of NotesDateTime. I think the Session scope works similar to beans in that it needs to be serializable. The NotesDateTime class isn't serializable.Rob Mason
thank you for the tip Rob - that was the problem - now it's working perfectly :o)Ursus Schneider
You're welcome Ursus.Rob Mason

1 Answers

4
votes

NotesDataTime is not serializable, so you cannot store it in the memory. When you use getComponent("datum").getValue(), it returns you Java Date not NotesDataTime. Java date is serializable, so its working. Try convert your NotesDataTime to Java Date.

dt.toJavaDate()