0

I have a document data source (create document with no parent id) bound to a panel. Within the panel I have 2 other panels. On completing the fields in panel 1 I click a link to reveal the 2nd panel and that has a save button on it. Once saved the document appears in the db correctly.

The save buttons does a dds save and then clears all fields and does a partial update on the outer panel and a partial execute on that panel too as I have other dds on the XPage outside of my main panel.

If I now create another document the previous document gets updated rather than create a new doc. I've tried different scope for the dds and other options. Not sure what to try next.

Anyone know what the problem is?

4

3 回答 3

9

下面是一个示例,如何通过部分刷新添加新数据源:

<xp:panel id="myPanel">
    <xp:this.data>
        <xp:dominoDocument var="document1"></xp:dominoDocument>
    </xp:this.data>
    <xp:br></xp:br>
    <xp:inputText id="inputText1" value="#{document1.Test}"></xp:inputText>
    <xp:br></xp:br>
    <xp:br></xp:br>
    <xp:button value="Save" id="buttonSave">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="myPanel">
            <xp:this.action>

                <xp:actionGroup>
                    <xp:saveDocument var="document1"></xp:saveDocument>
                    <xp:executeScript>
                        <xp:this.script>
                            <![CDATA[#{javascript:
                                var panel = getComponent("myPanel");
                                var ds = new com.ibm.xsp.model.domino.DominoDocumentData();
                                ds.setComponent(panel);
                                ds.setVar("document1");
                                panel.getData().clear();
                                panel.addData(ds);
                            }]]>
                        </xp:this.script>
                    </xp:executeScript>
                </xp:actionGroup>
            </xp:this.action>
        </xp:eventHandler>
    </xp:button>
</xp:panel>

希望这可以帮助

斯文

编辑:

添加了一个clear()以从面板中删除所有先前定义的数据源。

于 2013-01-29T14:26:50.473 回答
0

这是默认行为。如果您不想重新加载整个页面,一种选择是在单击“保存”按钮时删除数据源并在 SSJS 事件中创建新文档。

于 2013-01-29T14:05:11.063 回答
0

我成功使用了 Sven 的答案,但是,我不得不在服务器端 JavaScript 中添加额外的一行

<xp:executeScript>
    <xp:this.script>
        <![CDATA[#{javascript:
            var panel = getComponent("myPanel");
            var ds = new com.ibm.xsp.model.domino.DominoDocumentData();
            ds.setComponent(panel);
            ds.setVar("document1");
            ds.setFormName('form1');
            panel.getData().clear();
            panel.addData(ds);
            }]]>
    </xp:this.script>
</xp:executeScript>
于 2016-06-18T07:17:54.603 回答