This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 11, 2013, 6:27 PM
453 Posts
topic has been resolvedResolved

What is the dataSource of the XPage that contains a custom control

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: datasource
  • Replies: 5
I would like to compute the datasource of a custom control to be the same as the datasource of the primary XPage that the custom control resides. I know that I can do that by setting a Property Definition of the custome control to say ccDataSource  and DominoDocumentData , Method Binding. Then bind the ccDataSource to the XPage say document1 datasource. But in the case of what I am trying to do it would be much easier if from the custom Control I could get the XPages datasource directly.
Mar 12, 2013, 1:37 AM
366 Posts
Re: What is the dataSource of the XPage that contains a custom control
 When rendered the custom control becomes "part" of the XPage.  You only need one datasource that can be defined in the XPage and then just bind the custom control elements to the datasource defined in the "parent" XPage.
 
I usually define the datasource in both places for development purposes and then delete the duplicate Custom Control datasource one I'm done developing the Custom Control. 
 
You can also "manually" bind the elements of the custom control by just typing in the datasource name and the binding field name. 
 
 
Mar 12, 2013, 12:58 PM
50 Posts
Re: What is the dataSource of the XPage that contains a custom control
To expand on what Paul wrote, not only is it best practice to define your datasource in just one place, you will find that your application will start exhibiting "wierd" behavior at runtime if you have your datasources defined in both the XPage and in the Custom Control. I can't tell you how many hours I have spent troubleshooting "strange behavior" only to find that I had defined the datasource twice and forgot to remove one of them. Aarrrrrgh!
Mar 14, 2013, 9:33 PM
453 Posts
Re: What is the dataSource of the XPage that contains a custom control
My problem is that I am creating a Custom Control that I have no idea what the name of the datasource is going to be. I have been trying to do it by passing the datasource as part of the controls properties and strange behavior is right.
Mar 15, 2013, 12:10 AM
366 Posts
Re: What is the dataSource of the XPage that contains a custom control
 If you only have ONE document datasource you can use the global currentDocument variable.
 
 
Mar 18, 2013, 6:06 PM
453 Posts
Re: What is the dataSource of the XPage that contains a custom control
I think that I have got this resolved. It is really a combination of a number of issues.
 
 Because of the nature of the control (will be included in a database that will be extended by other developers) I need to set the datasource for the custom control. So I use the DominoDocumentData binding on the  top level custom control. This top level control in this case contains a tab table, I decided to create a new CC for each of the Tabs in the table as they will each contain a significant amount of data. So I created a ccGeneral, ccAccess, ccTechnical etc for each tab. I could allow the primary datasource to pass down to each of the ccGeneral etc but decided to keep them separate by binding a cc Property Definition on each of the sub controls ccGeneral/dsGeneral, ccAccess/dsAccess. On each of the tabs I bound the individual controls to the Tabs datasource using EL compositeData.dsGeneralTab['ACConditionToggle'] and setting the binding to be done on Page Load. I would assume that this is faster than leaving it as dynamic.
Next I have a cc that contains as series of controls that are used to set a value in a field on the main XPage document. So I created a ccPickNames that amounts other things contains an Extension Library Name Picker. The cc has a dsPickNames that gets bound back to the cc that contains it using the run time DominoDocumentData, because it will be used many different times and the names bound back to different document fields I pass the Property Definition bindToField. In the field that I want to bind back to the source document I use  the EL binding to compositeData.dsPickNames[compositeData.bindToField] but it does not work if you set the binding to On Document Load, it must be dynamic.
 
I'm sure that there is a better way of doing this but this works. So after trolling the internet and getting a little information from a lot of different sources I think I'm ready to get on with the job of actually building the application. I might have to wait a bit until my head stops hurting :-)
 
Thanks To all
 
Bill

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal