When I save the document from the extension library dialog, some values ​​are blank

Using 8.5.3 UP1

When I save the document in the dialog, some fields are not filled. If I save the document from xpage it saves those fields just fine. Here's a simple example to illustrate the problem:

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

      

+3


source to share


3 answers


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

Update: dataContexts or even DominoDocument datasource worked when saving the document, but the problem was that the values ​​were not saved. So I used the viewScope variable to store the values ​​and that did the trick. I'm 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!

+1


source


DOJO processes associated with dialog xe: move the dialog to a different location in the DOM, which means it will lose track of data sources in the main parts of the document. If you do a dialog save with SSJS instead of simple actions it might work better.

I have had the most success using a dialog contained in a custom control where the data source is passed through composite data. This way the data connection is not lost and continues to work, BUT I am still using SSJS to persist in these situations.

/ Newbs

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

First put a new event on 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>

      

Then activate the action in the dialog using client side javascript:

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

      

This "should" do it. I haven't tested it completely, but the examples from NoteIn9 do work.

/ Newbs

+5


source


Make sure your data is sent to the server before opening the dialog box. I would suggest opening a dialog like this with SSJS syntax - getComponent ("dialog1"). Show ()

0


source







All Articles