When I save a document from an extension library dialog box some values are blank

两盒软妹~` 提交于 2019-12-10 09:56:06

问题


Using 8.5.3 UP1

When I save my document from a dialog box certain fields are not being populated. If I save the document from within the xpage it saves these fields just fine. Here is a simple example to illustrate the issue:

    <xp:link text="Save Document By Dialog"
    id="link21">

    <xp:eventHandler event="onclick" submit="false">
        <xp:this.script><![CDATA[XSP.openDialog("#{id:dialog1}");]]></xp:this.script>
    </xp:eventHandler>
</xp:link>
<br/>
<xp:button value="Save By Button" id="button1">
    <xp:eventHandler event="onclick" submit="true"
        refreshMode="complete">
        <xp:this.action>
            <xp:saveDocument var="document1"></xp:saveDocument>
        </xp:this.action>
    </xp:eventHandler>
</xp:button>
<xe:dialog id="dialog1" title="Dialog">
    <br />
    <b>
        <xp:text escape="true" id="computedField1">
            <xp:this.value><![CDATA[#{javascript:"Save this document?"}]]></xp:this.value>
        </xp:text>
    </b>
    <br />
    <br />
    <xp:button value="Yes" id="button7">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="complete">
            <xp:this.script><![CDATA[XSP.closeDialog("#{id:dialog1}");]]></xp:this.script>
            <xp:this.action>
                <xp:saveDocument var="document1"></xp:saveDocument>
            </xp:this.action></xp:eventHandler>
    </xp:button>        
    <xp:button value="No" id="button8">
        <xp:this.onclick><![CDATA[XSP.closeDialog("#{id:dialog1}");]]></xp:this.onclick>
    </xp:button>
</xe:dialog>
<br/><br/>
<xp:inputText id="TitleTX" value="#{document1.TitleTX}"></xp:inputText>
<br/><br/>
<xp:inputRichText id="inputRichText1" value="#{document1.ProcessMapsRT}">
</xp:inputRichText>

回答1:


Have you tried using dataContexts to define your datasource? I believe dataContext is a global object.

Update: dataContexts or even dominoDocument datasource worked when saving a document, but the problem was that the values were not saved. I therefore used a viewScope variable to store the values and that did the trick. I am not sure if this will help you, but here you go, this works for me:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
    xmlns:xe="http://www.ibm.com/xsp/coreex">
    <xp:this.data>
        <xp:dominoDocument var="newDoc" formName="frmContact"></xp:dominoDocument>
    </xp:this.data>
    <xp:inputText id="inputText1" value="#{viewScope.firstName}"></xp:inputText>
    <xp:inputText id="inputText2" value="#{viewScope.lastName}"></xp:inputText>

    <xp:button value="Label" id="button1">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="dialog1">
            <xp:this.action><![CDATA[#{javascript:getComponent("dialog1").show();}]]></xp:this.action>
        </xp:eventHandler>
    </xp:button>

    <xe:dialog id="dialog1">
        <xp:button value="Label" id="button2">
            <xp:eventHandler event="onclick" submit="true"
                refreshMode="complete">
                <xp:this.action><![CDATA[#{javascript:newDoc.replaceItemValue("fldFirstName", viewScope.firstName);
newDoc.replaceItemValue("fldLastName", viewScope.lastName);
newDoc.save(); 
getComponent("dialog1").hide();}]]></xp:this.action>
            </xp:eventHandler>
        </xp:button>
    </xe:dialog>
</xp:view>

Hope this helps!




回答2:


The DOJO processes associated with the xe:dialog moves the dialog to another place in the DOM which means it will loose track of the data sources in the main parts of the document. If you do you saving in the dialog with SSJS instead of simple actions it may work better.

I have had the most success using a dialog contained in a custom control where the datasource is passed in through the composite data. That way the connection to the data is not lost and still works, BUT, I still use SSJS for saving in these situations.

/Newbs

UPDATE: This may be a time to use the technique Steve Pridemore described in NotesIn9 #42 (see xpages.tv).

First put a new event onto your XPage at the level with the data source in it.

<xp:eventHandler
    id="saveEventHandler"
    submit="true"
    save="true"
    event="calledbyid"
    refreshMode="complete">
</xp:eventHandler>

Next, have the action in the dialog invoke this event using client side javascript:

XSP.executeOnServer('#{id:saveEventHandler}')

That "should" do it. I have not fully tested it but the examples from NoteIn9 do work.

/Newbs




回答3:


Ensure your data are posted to server before opening dialog. I would suggest to open such dialog with SSJS syntax - getComponent("dialog1").show()



来源:https://stackoverflow.com/questions/10016205/when-i-save-a-document-from-an-extension-library-dialog-box-some-values-are-blan

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!