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

Go To StackoverFlow.com


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"

    <xp:eventHandler event="onclick" submit="false">
<xp:button value="Save By Button" id="button1">
    <xp:eventHandler event="onclick" submit="true"
            <xp:saveDocument var="document1"></xp:saveDocument>
<xe:dialog id="dialog1" title="Dialog">
    <br />
        <xp:text escape="true" id="computedField1">
            <xp:this.value><![CDATA[#{javascript:"Save this document?"}]]></xp:this.value>
    <br />
    <br />
    <xp:button value="Yes" id="button7">
        <xp:eventHandler event="onclick" submit="true"
                <xp:saveDocument var="document1"></xp:saveDocument>
    <xp:button value="No" id="button8">
<xp:inputText id="TitleTX" value="#{document1.TitleTX}"></xp:inputText>
<xp:inputRichText id="inputRichText1" value="#{document1.ProcessMapsRT}">
2012-04-04 17:21
by Dan Herman


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"
        <xp:dominoDocument var="newDoc" formName="frmContact"></xp:dominoDocument>
    <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">

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

Hope this helps!

2012-04-06 15:11
by pipalia
Can you specify some sample code so I make sure to do it right? Thank - Dan Herman 2012-04-06 16:52
I tried working with viewScopes and while it did not actually work for my situation, it did lead me down a path that DID work. I ended up just making an call to the server before opening the dialog and this did fix it. Made my link like this: XSP.partialRefreshPost("#{id:TitleTX}", { onComplete: function() { XSP.openDialog("#{id:dialog5}", {} )} }) Thanks for the help - Dan Herman 2012-04-13 18:33
That's great - thanks for sharing Dan - pipalia 2012-04-13 18:49


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.


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.


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


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


2012-04-04 21:51
by Newbs
Thanks for reply. I tried saving the document with SSJS and it still doesnt work. Here is the updated dialog button code: <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><![CDATA[#{javascript:document1.save();}]]></xp:this.action> </xp:eventHandler> </xp:button> How did you pass the datasource in through to your custom control? Do you have an example I could try? Thank - Dan Herman 2012-04-05 15:55


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

2012-04-05 07:03
by Frantisek Kossuth
thanks for the suggestion. I tried to use SSJS code to open the dialog but it didn't seem to make any difference - Dan Herman 2012-04-05 15:56
have unsaved fields something in common? what type of controls are they? do you set their values by code, or are they typed in by user - Frantisek Kossuth 2012-04-05 20:13
My specific problem is a couple of rich text controls and text fields that are bound dynamically. If I save them with a button on the xpage, no problem. But from the dialog box those fields are ignored - Dan Herman 2012-04-06 16:51