Xpages 更新NotesDocument不会更新绑定的notesxpdocument

Xpages 更新NotesDocument不会更新绑定的notesxpdocument,xpages,Xpages,我试图理解XPage上的数据源与其对应的NotesDocument之间的关系 print('doc2 lastname: ' + doc2.getItemValueString('lastName')); 我有两个数据源doc1和doc2绑定到一个XPage,其中各个字段绑定到第一个或第二个文档doc1由用户填写,但我使用带有typeahead的文本框搜索要绑定到doc2的文档。当用户单击typeahead中的一个结果时,我尝试将找到的文档附加到doc2,但它不起作用。有人能解释一下我

我试图理解XPage上的数据源与其对应的NotesDocument之间的关系

    print('doc2 lastname: ' + doc2.getItemValueString('lastName'));
我有两个数据源
doc1
doc2
绑定到一个XPage,其中各个字段绑定到第一个或第二个文档
doc1
由用户填写,但我使用带有typeahead的文本框搜索要绑定到
doc2
的文档。当用户单击typeahead中的一个结果时,我尝试将找到的文档附加到
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

另外,我不确定是否需要
doc2
上的
action
参数。我认为只有当参数是页面上唯一的数据源时才需要它

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,它没有后端文档

    print('doc2 lastname: ' + doc2.getItemValueString('lastName'));
因此,无法从中检索任何内容

数据源在前,文档在后

如果要将找到的文档附加到doc2,则必须将viewScope.providerUNID设置为其noteID,并部分刷新引用doc2的代码部分。例如,您可以创建一个新的xp:panel并将doc2的定义移动到那里,以便在刷新该面板时加载数据源


HTH

只是在工作流路径上再进一步,最终会保存哪个文档?doc1或doc2或两者都有?@PaulDella Nebbia-最终两者都被保存为单独的文档。我确实将一些冗余字段从doc2复制到doc1,但总体上它们包含不同的数据。感谢您的澄清。我没有将
doc2
绑定到页面,而是添加了一个
xp:panel
,将
doc2
xp:inputText
字段移动到其中。在
onChange
事件中,我从
doc2
更新了
viewScope.providerUNID
,并刷新了面板,一切正常。