Search code examples
javascriptjavaxpagesxpages-ssjs

XPages | Replication Save Conflict


I have a document data source defined in a xPage and I am calling a java class when a file upload control is changed. The java class compresses the image uploaded via the file upload control, then attaches it to the Notes Document. When I click the save button on the xPage (custom javascript, set to save the datasource) it creates a replication or save conflict.

I'm assuming this conflict is being created because I'm saving the data source in SSJS and the document in java. Is there any trick to prevent the save conflict?


Solution

  • The best "trick" would be to turn your Java class into a managed bean (ViewScope) and bind your input fields not to a document, but properties of the Java bean. Handle the save to the document inside the Java bean. Then you have a single point of save. Keep in mind: you can't keep a document handle around between function calls, so in your bean you would just keep the document id around and grab it when needed. This also mitigates the risk of a save conflict if someone else updates the document inbetween.