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 9, 2011, 4:08 PM
57 Posts

Xpages Runtime

  • Category: APIs
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: runtime datasource
  • Replies: 2
My question is about Xpages runtime modal binding.

All the click click properties in Xpages , i have been using their naive functions with Java. Its all fine untill I hit

com.ibm.xsp.model.domino.DominoViewDataModel.getDominoViewData().getDataObject()

is that possible to replace the viewData by using setWrappedData? I have tried most of the methods, but nothing ever has any impact. the only one that works is v.setDominoViewDataContainer(xspData);

All I can guess is that viewData which is configured in Xpages is totally locked...am I right? anyone using java at back end to create/manipulate datasouce?
Mar 13, 2011, 8:34 AM
41 Posts
Re: Xpages Runtime
 Here is an example of adding a new data source to an XPage at runtime:
 

var viewDataSource = new com.ibm.xsp.model.domino.DominoViewData();

viewDataSource.setViewName("($All)");

viewDataSource.setVar("allDocuments");

view.addData(viewDataSource); 
 
In order for this technique to be of use, however, other components must reference it by its var (in the above example, allDocuments). Unless you're also injecting all of those components at runtime as well, they're referring to a data source that already exists. So here's a function that should do what you're attempting (read: I haven't tested it, but it works in my mind).
 

function replaceViewData(oldDataSource, newViewName) {

var viewDataSource = new com.ibm.xsp.model.domino.DominoViewData();

viewDataSource.setViewName(newViewName);

viewDataSource.setVar(oldDataSource.getVar());

view.getData().remove(oldDataSource);

view.addData(viewDataSource);

}

 
You would pass a handle on the existing data source and the name of the view you want to switch to. Theoretically, you could just call setViewName() on the original data source, and - again - it should switch to using the view matching the name you pass... but I'd be far more confident that removing the data source entirely and injecting a new one would work.
 
Also, keep in mind that data sources can be bound to a panel as well as to the entire ViewRoot, so if your data source is in a panel, you'd need to reference that panel when removing the old data source and adding the new, instead of the ViewRoot. 
 
One final word of caution: if you're using a view panel - or any other components that make assumptions about the name or sequence of columns in the view - you will encounter problems if you replace an existing view data source with one whose columns cause those assumptions to no longer be accurate. For example, if a view panel includes a column that exists in the original view but not the one you're replacing it with, the entire page will 500. So you may need to inject / remove / replace additional components as well when swapping out a data source. This would apply equally when changing the form to which a document data source is bound.
Apr 3, 2011, 9:38 PM
57 Posts
Re: Xpages Runtime
HI Tim
 
did not have time to try out all the pespectives in your answer untill now, the code to replace a datasource at runtime works.
really appreciate your help
 
regards
wei

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