0
votes

I have an Xpage with multiple custom controls that make up a form. When I click the submit button I get a multiple documents saving the multiple custom control data as a separate document. I have the data sources configured at the custom control level.

How can I make it that all the custom control save the data to one single document?

Thanks,

2

2 Answers

1
votes

Just put them on the XPage. If you use a variable name (e.g. for a datasource, a dataContext etc), the runtime will just look outwards from the current component in the hierarchy to find the relevant object. If you're having problems thinking of the XML source code in a three-dimensional way, the Outline view is good for this.

So from within a Custom Control, you can reference a datasource on the XPage, as long as it is defined in an ancestor of the custom control on the XPage or is a previous sibling. So in the structure below, document1 will be accessible from anywhere in the ccFriends custom control.

<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
    xmlns:xc="http://www.ibm.com/xsp/custom">

    <xp:this.data>
        <xp:dominoDocument var="document1" formName="Profile">
        </xp:dominoDocument>
    </xp:this.data>
    <xc:ccFriendsAlt></xc:ccFriendsAlt>
1
votes

You can also pass the data source object as a custom property to the custom control if you can't follow Paul's suggestion of keeping the same variable name for your data source. http://lpar.ath0.com/2013/04/22/passing-document-data-objects-to-xpages-custom-controls/