【发布时间】:2016-12-09 14:40:23
【问题描述】:
我在使用 XPage 时遇到了奇怪但可重现的行为,该 XPage 通过 Java bean 保存其值。将所有项目复制到文档后,文档中有两个富文本项目。第一个为空,第二个按预期填充。
这是我的 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>
这是我的 java bean 方法:
public void testCopyAllItems(DominoDocument docDataSource) throws NotesException{
Document docUser = database.createDocument(); // <- get any database
docDataSource.getDocument(true).copyAllItems(docUser, true);
docUser.save();
}
这是文档中的结果:
有没有人暗示什么会导致麻烦?
【问题讨论】:
-
这似乎是一种“正常”的行为,我已经看到很多使用 RichtText 字段的情况。没关系。 Notes 可以处理包含多个项目的 RichText 字段。
-
但是当我想以编程方式访问文档以获取 RichText 项时,我得到一个空字段。
-
然后用
removeItem()删除copyAllItems()后面的RichText字段,再用copyItem()分别复制,希望结果只有一个。 -
这对我有用。把它写成答案,这样我就可以接受了。非常感谢!
-
太好了,谢谢,我把这个放在答案里了。
标签: xpages javabeans lotus-notes