xpages - 更新 NotesDocument 不会更新绑定的 NotesXspDocument
问题描述
我试图了解 XPage 上的数据源与其对应的 NotesDocument 之间的关系。
我有两个数据源doc1
并doc2
绑定到 XPage,其中各种字段绑定到第一个或第二个文档。 doc1
由用户填写,但我使用带有预输入的文本框来搜索要绑定到doc2
. 当用户单击预先输入的结果之一时,我尝试将找到的文档附加到,doc2
但它不起作用。有人可以解释我做错了什么吗?
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument var="doc1" formName="form1"
documentId="#{sessionScope.clientUNID}" databaseName="${sessionScope.ClientsDbPath}"
action="#{viewScope.DocEditMode}" ignoreRequestParams="true" />
<xp:dominoDocument var="doc2" formName="form2"
documentId="#{viewScope.providerUNID}" databaseName="${sessionScope.ProvidersDbPath}"
action="#{viewScope.DocEditMode}" ignoreRequestParams="true" />
</xp:this.data>
<xp:inputText id="providerFullName" value="#{doc1.providerFullName}">
<xp:this.attrs>
<xp:attr name="placeholder" value="Last name..." />
</xp:this.attrs>
<xp:typeAhead mode="partial" minChars="1" ignoreCase="true"
valueList="#{javascript:@DbColumn(sessionScope.ProvidersDbPath, 'providerLookup', 1)}" />
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="panel1"
disableValidators="true">
<xp:this.action><![CDATA[#{javascript:
var pDB:NotesDatabase = session.getDatabase(sessionScope.ServerName, sessionScope.ProvidersDbPath);
var pView:NotesView = pDB.getView('providerLookup');
var result = getComponent('providerFullName').getValue();
var tmpDoc:NotesDocument = pView.getDocumentByKey(result, true);
if (tmpDoc != null) {
//here I am trying to associate the found doc with the data source
var prDoc:NotesDocument = doc2.getDocument();
prDoc = tmpDoc;
//the back-end assignment works because this DOES return the last name
print('prDoc lastname: ' + prDoc.getItemValueString('lastName'));
//then I try to update the Xsp doc from the changed back-end doc but it returns nothing
doc2.getDocument(true);
print('doc2 lastname: ' + doc2.getItemValueString('lastName'));
}}]]></xp:this.action>
</xp:eventHandler>
</xp:inputText>
</xp:view>
数据源关系是否只有单向关系?也就是说,如果 NotesDocument 以编程方式更新,我是否只能将数据从 XspDocument 推送到 NotesDocument(通过输入文本字段),但不能将数据从 NotesDocument 推送回 XspDocument?
另外,我不确定是否需要action
on 参数doc2
。我认为只有当它是页面上的唯一数据源时才需要该参数......?
解决方案
if (tmpDoc != null) {
//here I am trying to associate the found doc with the data source
var prDoc:NotesDocument = doc2.getDocument();
在这里你扔掉 doc2.getDocument 的结果......
prDoc = tmpDoc;
//the back-end assignment works because this DOES return the last name
print('prDoc lastname: ' + prDoc.getItemValueString('lastName'));
//then I try to update the Xsp doc from the changed back-end doc but it returns nothing
doc2.getDocument(true);
viewScope.providerUNID 是否包含有效的 noteID?如果不是,则 doc2 是一个临时的 DominoDocument,它没有后端 Document。
print('doc2 lastname: ' + doc2.getItemValueString('lastName'));
因此,无法从中检索任何内容。
首先是数据源,其次是文档。
如果要将找到的文档附加到 doc2,则必须将 viewScope.providerUNID 设置为其 noteID 并部分刷新引用 doc2 的代码部分。例如,您可以创建一个新的 xp:panel 并将 doc2 的定义移动到那里,这样当您刷新面板时,将加载数据源。
高温高压
推荐阅读
- linux - 使用 centos 7 作为操作系统对安装在谷歌云实例上的 tableau 服务器进行 Web 访问
- splunk - Splunk 只选择匹配的 JSON 数据
- windows - 使用 Powershell 自动禁用 Windows 更新
- javascript - 使用“index.js”导入 ES6 JS 模块的问题
- java - 如何安装 JDK 和 JRE
- json - 在 Google 表格中解析 JSON
- for-loop - Jekyll 中的嵌套液体循环不会正确地迭代多个子项
- javascript - 如何在 html 文件上显示 ejs 数据?
- email - 从 google 用户 ID 获取电子邮件(反之亦然)
- sql - 如何排除数据集中的某些组合模式?