Paul Wither suggests using the requestScope scope for data sources, making the code pretty simple:
XPage
<xp:div styleClass="container" style="margin-top:20px">
<xp:div styleClass="row">
<xc:cc1></xc:cc1>
<xc:cc2></xc:cc2>
</xp:div>
custom control 1
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument var="form1" formName="form1" scope="request"></xp:dominoDocument>
</xp:this.data>
<xp:div id="formDiv1" styleClass="col-sm-4">
<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 id="field1" value="#{form1.field1}"></xp:inputText>
</xp:div>
<xp:button value="Save" id="form1Btn">
<xp:eventHandler event="onclick" submit="true" refreshMode="partial" immediate="false" save="false" execMode="partial" execId="formDiv1"
refreshId="formDiv1">
<xp:this.action>
<xp:actionGroup>
<xp:saveDocument var="form1"></xp:saveDocument>
</xp:actionGroup>
</xp:this.action>
<xp:this.onComplete><![CDATA[x$("#{id:field1}").val("");]]></xp:this.onComplete>
</xp:eventHandler>
</xp:button>
</xp:div>
</xp:view>
user control 2
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument var="form2" formName="form2" scope="request"></xp:dominoDocument>
</xp:this.data>
<xp:div id="formDiv2" styleClass="col-sm-4 ">
<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 id="field1" 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="false" execMode="partial"
execId="formDiv2" refreshId="formDiv2">
<xp:this.action>
<xp:actionGroup>
<xp:saveDocument var="form2"></xp:saveDocument>
</xp:actionGroup>
</xp:this.action>
<xp:this.onComplete><![CDATA[x$("#{id:field1}").val("");]]></xp:this.onComplete>
</xp:eventHandler>
</xp:button>
</xp:div>
</xp:view>
source
share