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



May 2, 2012, 4:08 PM
67 Posts
topic has been resolvedResolved

Use docSource defined in Xpage in CC

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 7
 Hi,
 
I've defined a doc-datasource  in xpage which works within the xpage (i can use fields of it).
Then i made a simple cc embeded in that xpage and i want  to work there with fields of the datasource also.
 
But debugger says 'doc not found'. What can i do to pass the datasource ? 
 
Thanks 
Uwe 
May 3, 2012, 7:15 AM
126 Posts
Re: Use docSource defined in Xpage in CC
Theres nothing stopping you using a doc datasource in a custom control.
 
I'll need  more details like how are you trying to open the doc ? are you passing in a doc id? searching for one based on a key? etc.
 
May 3, 2012, 8:51 AM
67 Posts
Re: Use docSource defined in Xpage in CC
 Hi Simon,
 
i've tried to test the access to the document with a statement like this:
 
<xp:label value="#{doc1.lang}" id="label1"></xp:label> 
 
On the Xpage (where the document is opened)   the field content  appears.
 
In the area of the emdedded CC there apears nothing in one case. 
But in case of a second CC  (on the same  Xpage)  the field content  appears also.
 
I can't see the difference ?? You mentioned something about passing parameters of the doc to the cc. 
 
How should i do this ? I want to prevent to open the doc again. Or is that necessary ?
 
Thanks 
Uwe 
 
May 3, 2012, 9:18 AM
126 Posts
Re: Use docSource defined in Xpage in CC
Hi,
 
There is no difference in opening a domino doc in a custom control verses in an XPage. you defeine a data source and then you provide some means for it to query which document your interested in by:
  • Adding "documentId=..." to the URL
  • adding a scoped variable as a binding to the docId property of the datasource
  • searching the data source via server side script to get documents by keys / categories of some kind
If you are unsure how to deal with documents in XPages as a whole then you should look into some examples. There are templates that come with XPages that can be deployed, I've modernized 2 of them and they are currently on openNTF.org as part of the ExtLib project (Discussion / Teamroom). These would be good examples to look at and web sites like:
 
May 3, 2012, 9:32 AM
67 Posts
Re: Use docSource defined in Xpage in CC
 To say it in short words: i have to open the datasource again in the CC. That's not great under performance aspects.
 
Thank you 
 
May 3, 2012, 9:44 AM
126 Posts
Re: Use docSource defined in Xpage in CC
 no your not opening a document a second time. the datasource is a connection to the domino back end.  you have to provide it details of what it is ur looking for. the same way when using a JDBC connection you can't create one and ask for fied 1 of a result set before you do the query. 
 
without an id or a search of some kind a datasource is just a blank connection 
May 3, 2012, 3:55 PM
47 Posts
Re: Use docSource defined in Xpage in CC
There are (at least) two ways to access a document data source from within a custom control:
 
 1) use the 'currentDocument' object. This should be all you need if there is only one document datasource in use on your xpage. If there is more than one document data source on your page, it will find the 'closest' document, by walking back up the control tree. If you need to control which doc datasource you really need to work with, use method 2. 
 
2)  You can pass the document datasource as a property of the custom control. You create a property with the type com.ibm.xsp.model.ModelDataSource (type it in, it doesn't show up as a choice), then pass your datasource as the value of that property where you instantiate your custom control. Then you access that datasource through the compositeData object in your custom control. In any javascript computation, I find is useful to define a local variable and cast it as a NotesXspDocument to get the advantages of type-ahead in the editor:
 var doc:NotesXspDocument = compositeData.datasourceProperty; 
Rich 
May 3, 2012, 7:46 PM
67 Posts
Re: Use docSource defined in Xpage in CC
Richard, that is very interesting.
 
I've tried method 2 and it worked !!
 
Thank you very much ..... 
Uwe 

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