0
votes

I have a strange thing, I'm using dynamic field binding in a custom control.

The field binding is created like this.

  • XPage (Datasource "document" is placed here)
    • Custom Control (String passed in) (to get errors if there are any)
      • Repeat (CompositeData is passed to a bean that returns the strings for Rows,columns)
        • Repeat (repeat 1 variable used for Columns)
          • Custom Control (fieldname is passed in)

field binding is done like this #{document[compositeData.fieldName]}

The problem is that when I save the XPage I get an error in the messages control

Document has been saved by another user - Save created a new document as a response to that modified document.

And all fields are cleared.

Any ideas how to debug this or is there something I'm missing?

4

4 Answers

1
votes

The "Document has been saved by another user" error is only tip of the iceberg - there are some really strange problems with reapeats that repeats fields that are bound and repeatControls property is set to false. The decoding part of xpages lifecycle cannot handle it properly - the controls will be losing data. You should use repeatControls set to true as Martin suggests.

"Repeat control variable doesn't exists" is probably caused by the property that removes repeats set to true. You can solve this by either changing it to false or by adding additional data context that will keep repeated value.

And finally for this to have add/remove functionality You can use Dynamic Content Control and show(null) hack to rebuild the repeat content.

To manage this complexity better I would advise You to stop using document data source and start creating some managed beans.

If You will follow my suggestions I guarantee that You will get the functionality You are looking for as I have few apps that works great and have this kind of complex data editors in them.

1
votes

I don't know if it'll help you, but I pass both the document datasource and the field name as parameters to a DynamicField control, and use it like this:

compositeData.dataSource[compositeData.fieldName]

The type of the datasource is com.ibm.xsp.model.DataSource, it's listed as dataInterface under Data Sources.

0
votes

Do you have repeatControls="true" set for the repeat control?

0
votes

It sounds like you've got the datasource defined multiple times on the XPage (plus custom controls). Either that or the save button has save="true" but the code saves the document back-end, or code in multiple places saves the same document. I've used the same method of passing the datasource down to the custom control, but that may just be because that was what I saw on a blog.