Max
Max

Reputation: 1220

duplicate items in Document after saving in a bean

I experience strange but reproduceable behaviour with an XPage which saves its values through a java bean. After copyAllItems to an document there are two richtext items in the document. First is empty, second is filled as expected.

This is my Xpage:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xc="http://www.ibm.com/xsp/custom">
<xp:this.data>
    <xp:dominoDocument var="docDataSource" formName="test"></xp:dominoDocument>
</xp:this.data>
<xp:div id="test">
    <xp:fileUpload id="fileUpload1" value="#{docDataSource.test}"></xp:fileUpload>
</xp:div>
<xp:button value="Label" id="button1">
    <xp:eventHandler event="onclick" submit="true"
        refreshMode="partial" refreshId="test">
        <xp:this.action><![CDATA[#{javascript:registration.testCopyAllItems(docDataSource);}]]></xp:this.action>
    </xp:eventHandler>
</xp:button>

This is my java bean method:

public void testCopyAllItems(DominoDocument docDataSource) throws NotesException{
    Document docUser = database.createDocument(); // <- get any database
    docDataSource.getDocument(true).copyAllItems(docUser, true);
    docUser.save();
}

This is the result in the document:

enter image description here

Does anyone have a hint on what could cause the trouble?

Upvotes: 3

Views: 90

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30970

This seems to be a "normal" behaviour and I have seen it a lot working with RichtText fields. It shouldn't matter. Notes can deal with a RichText field constisting of more than one item.

As a workaround,

  • delete the RichText field after copyAllItems() with removeItem() and
  • copy it with copyItem() separately.

This should result in one item only.

Upvotes: 2

Related Questions