0
votes

I have an XPage that is saving a document inside SSJS with document1.save(). After this, I call some Java code to do some additional processing of the document and the new data that was saved; I pass document1.getDocument() in to the Java function. In the Java function, it calls Document.save() to save the document again. This seems to be a recipe for getting a save conflict, and I don't know why. Can anyone explain what's happening? TIA! (In addition to understanding why this is happening, if anyone has suggestions for a better way to do what I'm doing, I'd appreciate it.)

Reid

1
Can you try to pass the document using getDocument(true) ? This might prevent creating a save conflict...Michael Ruhnau
Hi Michael. If I use getDocument(true) when passing the Document to my java code, I still get a save conflict unfortunately. One thing I've noticed is that if I use document1.getDocument().save() instead of document1.save() in my SSJS, I don't get a conflict. It seems to save the changes correctly, though I need to test that a bit more. It doesn't seem quite right to do that....Reid Rivenburgh
Have you tried to only do the save in java?Per Henrik Lausten
Per: I have not. Is it true that java has no awareness of a NotesXspDocument? It seems like not doing the document1.save() in SSJS and instead doing Document.save() in java is basically the same as what I tried, which is calling document1.getDocument().save() in SSJS. Is that true...? And should it work correctly, as it seems to?!Reid Rivenburgh
SSJS is Java and your Java code can have knowledge of the NotesXspDocument. I will add an answerPer Henrik Lausten

1 Answers

1
votes

You can use "resolveVariable" in Java to get hold of your NotesXspDocument (which is called DominoDocument in Java). You can then do your save on the DominoDocument object in Java instead of in SSJS.

If you use JSFUtil (which is found in many XPages open source projects) or use your own helper method, you can then do this to get hold of your DominoDocument (replace "currentDocument" with the name of your document data source):

DominoDocument uidoc = (DominoDocument) JSFUtil.resolveVariable("currentDocument");

The resolveVariable method looks like this:

public static Object resolveVariable(final String variable) {
    return FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(FacesContext.getCurrentInstance(), variable);
}