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



Jun 17, 2013, 5:10 AM
12 Posts

How to pass var variable to custom control

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: control
  • Replies: 5

I want to create a generic action bar custom control with Save, Edit, Delete, ... buttons.

How can I pass var variable from xpage to custom control?

 

Jun 17, 2013, 12:18 PM
4 Posts
compositeData?
Sounds like a scenario where a custom property might be handy. Define the custom property on the control instance in the XPage, and then access the value in the custom control with compositeData.<varname>. Either that, or a scoped variable, like viewScope.varName.
Jun 17, 2013, 4:23 PM
586 Posts
further info

Paul Hannan just tweeted that there are some answers to this on stack over flow..  So you might want to check there.

I know Matt white had a demo once with this exact custom control in - Save, Edit, Delete.  Possibly it was in the first Xpages Show and Tell that he and Tim did.  Not sure.

This is something I've wanted to do as well, just not really gotten to it so I don't have any experience to draw on.  You can certainly pass the name in via custom properties and then get it back as Michael says. 

 

As I type this I can See Tim Tripcony just tweeted:

 

 

<xc:myControl dataSource="#{someDocument}" /> Define the custom property as a dataInterface.

 

dataInterface is new to me.  I've used generic "Object" before.

Jun 18, 2013, 6:12 PM
453 Posts
Passing a data source to a custom control

I have created a similar "button Bar" custom control that I need to use on different XPages and on an XPage where there are two different datasources, Also it is in an application that will be reused by other designers so I have no control over dataSource naming. So I need to ensure that when I click Save I am in fact saving the correct dataSource. So here is what I did:

1. on the Custom Control create a Custom Property and call it say dsButtonBar

2. for Type enter com.ibm.xsp.model.ModelDataSource and the editor as String value then in Validation make it required.

3. Now in your custom control  the dataSource in the Custom Control can be accessed via compositeData.dsButtonBar.

After inserting the ccButtonBar into your XPage go to the Custom Properties and enter the dataSource that is linked to this CC. Note -- enter the dataSource as a computed Value so it appears in the Value Column as "# document1" or whatever the linked dataSource needd to be.

Jun 20, 2013, 7:00 AM
12 Posts
Partial success

I successfully transferred document object to custom control and I can Save the changes made in document, but I can't delete it with same object.

Update:

<xp:this.action>
    <xp:executeScript
        script="#{javascript:compositeData.datasrc.save()}">
    </xp:executeScript>
</xp:this.action>

Delete is not working:

<xp:deleteDocument
    message="Do you want to delete?"
    var="#{javascript:compositeData.datasrc}">
    <xp:this.name><![CDATA[#{javascript:var page = sessionScope.get("prevview");
    return (page=='')?'home.xsp':page}]]>    </xp:this.name>
</xp:deleteDocument>

I tried also with:

var="#{javascript:compositeData.datasrc.getDocument()}">

but also didn't work.

Jun 20, 2013, 4:25 PM
54 Posts
passing data

What do you want to achieve??

The save, delete and i.e. edit should act on the current document?

Then you don´t need to passing values from the doc to the cc.

The current document is always the default data source on which the code is working on.

Or did I misunderstood your request??


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