Ursus Schneider
Ursus Schneider

Reputation: 467

XPages sessionScope variable and DateTime values

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

Upvotes: 1

Views: 485

Answers (1)

Hubert
Hubert

Reputation: 146

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

Upvotes: 4

Related Questions