0
votes

I have a Java bean that represents all of the functionality behind my xpage. When I save the xpage a method is called and I pass in my xpage data source as a DominoDocument object. The problem I have is when it comes to setting the Author and reader fields. I can't get the Item object in order to use "item.setAuthors(true);" with the DominoDocument object so I have to get the Document object instead:

(dDoc = DominoDocument passed into the save method via SSJS call to it)

Document doc = dDoc.getDocument(true); 
Vector<String> editors = new Vector<String>();       
editors = getUniqueList(dDoc,editors,"AdditionalEditors") ;  
Item item = doc.replaceItemValue("Authors", editors);  
item.setAuthors(true) ; 
doc.save(); 

The first save of a new document appears to work, however subsequent saves create a new duplicate copy of the current document; the back end change isn't being passed through to the front end document. Is there an alternative way to set an authors/readers field with the dominoDocument object or to wrap the DominoDocument with the changes after calling a save with the backend document. I did try dDoc.restoreWrappedDocument() but that didn't work ether.

1
What if you ommit the save method at the end of your code? Try to invoke your bean code and then call a simple action "Save Document". Maybe you should return the document object from your bean method to the facesContext before calling the "Save Document" action.Oliver Busse
It is important where you call the code. You should put it into querySave event of document data source.Frantisek Kossuth

1 Answers

0
votes

To get Author and Reader fields going you have 2 options:

  • Add them to the form and specify "ComputeWithForm" for the save operation
  • Add code to the querySave event where you set the field. Don't SAVE the document there (it is the function that runs before the document is saved anyway).

In any case make sure you don't keep the reference to dDoc in any scope