If I understand correctly, the reason why he creates a new document every time is because your bean has no idea which document he is dealing with. With the dominoDocument data source in XPage, this is handled by the action and documentId properties of the data source. Therefore, calling the save method in this data source not only saves the backend database, but also updates these actions and the documentId properties of the data source. As a result, any future action knows to which document it should act, since documentId was changed from an empty line to the UNID of the created backend document. Also, the action has been changed from "createDocument" to "editDocument".
If you use a bean, your save method should mimic this process by setting the variables for which the document should act. Then your save method should check if this property has a value, and in this case get the corresponding document, otherwise create a new one. Otherwise, your bean can only create documents, it will never be able to update them.
If you are not using an xe: dataObject, you should also not use a button like submit. beans do not know what to do with it. John will be a beer to confirm, but I donโt know if MVC will know what to do with it. xe: dataObject has a specific saveObject property, as it is. Itโs easier to just use a regular button and on the Events tab point it to the appropriate save method.
Using beans, xe: dataObject or MVC, you still need to specify the code when creating the document and when / how to get it for updating.
source share