Search code examples
formsxpageslotus-domino

Xpage with multiple forms and data sources create empty documents


  • I have a two simple forms (Form1 and Form2). They have only one field each (field1). I created two custom controls. They are identical except cc1 has data source defined as Form1 and cc2 has a data source of Form 2.
  • Each custom control has one inputbox bound to the field1 field of the corresponding data source, and one submit button. I create an
    Xpage and pull both custom controls into the page.
  • If I preview and fill out the input boxes on the Xpage in a browser, when I click on any of the submit buttons, two documents will be created based on the two forms in the domino database.
  • I tried to use partial refresh/execution and lots of other things. No matter what I do, I always get empty documents of both Forms.

XPage:

<xp:div styleClass="container" style="margin-top:20px">
   <xp:div styleClass="row">
     <xc:cc1></xc:cc1>
     <xc:cc2></xc:cc2>
   </xp:div>
 </xp:div>

Custom control 1

 <xp:this.data>
    <xp:dominoDocument var="form1" formName="form1"></xp:dominoDocument>
  </xp:this.data>
  <xp:div id="formDiv1" styleClass="col-sm-4">
    <xp:form>
      <xp:label value="Form 1" styleClass="h3"></xp:label>
      <xp:div styleClass="form-group">
        <xp:label value="Field 1" styleClass="control-label"></xp:label>
        <xp:inputText value="#{form1.field1}"></xp:inputText>
      </xp:div>
      <xp:button value="Submit Form1" id="form1Btn">
        <xp:eventHandler event="onclick" submit="true" refreshMode="partial" immediate="false" save="true" refreshId="formDiv1"
          execMode="partial" execId="formDiv1">
        </xp:eventHandler>
      </xp:button>
    </xp:form>

Custom control 2

 <xp:this.data>
    <xp:dominoDocument var="form2" formName="form2"></xp:dominoDocument>
  </xp:this.data>
  <xp:div id="formDiv1" styleClass="col-sm-4">
    <xp:form>
      <xp:label value="Form 2" styleClass="h3"></xp:label>
      <xp:div styleClass="form-group">
        <xp:label value="Field 1" styleClass="control-label"></xp:label>
        <xp:inputText value="#{form2.field1}"></xp:inputText>
      </xp:div>
      <xp:button value="Submit Form2" id="form2Btn">
        <xp:eventHandler event="onclick" submit="true" refreshMode="partial" immediate="false" save="true" refreshId="formDiv1"
          execMode="partial" execId="formDiv1">
        </xp:eventHandler>
      </xp:button>
    </xp:form>


Solution

  • A normal submit button gets the property save="true" and saves all data sources.

    If you want to save only one data source then use the simple action Save Document and select the data source:

    enter image description here

    Set property save="false" in addition. Your button code would look like this then:

    <xp:button
        id="form1Btn"
        value="Submit Form1">
        <xp:eventHandler
            event="onclick"
            submit="true"
            refreshMode="complete"
            immediate="false"
            save="false">
            <xp:this.action>
                <xp:saveDocument
                    var="form1"></xp:saveDocument>
            </xp:this.action>
        </xp:eventHandler>
    </xp:button>