XPages save data source and new doc changes previous doc

后端 未结 3 1296
感动是毒
感动是毒 2021-01-17 04:58

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 lin

相关标签:
3条回答
  • 2021-01-17 05:15

    Here is a example how you can add a new datasource with a partial refresh:

    <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>
    

    Hope this helps

    Sven

    EDIT:

    Added a clear() to remove all previous defined datasources from the panel.

    0 讨论(0)
  • 2021-01-17 05:26

    I used Sven's answer succesfully, however, I had to add an extra line in ths server side 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>
    
    0 讨论(0)
  • 2021-01-17 05:31

    That's default behaviour. If you don't want to reload the whole page one option is to get rid of the datasource and create the new doc in SSJS event when Save button is clicked.

    0 讨论(0)
提交回复
热议问题