Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 924
Max Avatar asked Dec 13 '25 14:12

Max


1 Answers

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.

like image 103
Knut Herrmann Avatar answered Dec 16 '25 11:12

Knut Herrmann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!