Bill F
Bill F

Reputation: 2087

How to dynamically specify the file name for a datasource

On a custom control I want to bind the datasource to a database other than the current one. So I have selected the other option and selected the database from the list provided. All is well but I want this to be not dependent on the location of the database. I have created a profile document and stored the repID of the db I want to target and added this code to the Other option:

var repID = database.getProfileDocument("frmConfigProfile","").getItemValue("WFSRulesRepID")[0];
session.getDbDirectory(null).openDatabaseByReplicaID(repID).getFilePath();

This code returns the correct FilePath and Name, but the code fails when I try to open a document in the target DB. Do I need to specify the server as well as the filePath?

Upvotes: 0

Views: 124

Answers (2)

Per Henrik Lausten
Per Henrik Lausten

Reputation: 21709

Yes, add server name also. Here's an example where you just need to add your own file path logic:

<xp:this.databaseName><![CDATA[#{javascript:
  var fileName = ...;
  return database.getServer() + "!!" + fileName
}]]></xp:this.databaseName>

Upvotes: 2

Patrick Sawyer
Patrick Sawyer

Reputation: 1382

I would not use profile documents with xPages. In order to see new changes to the profile document the HTTP task needs to be restarted.

I would try and replicate the functionality of a profile document with some other functionality.

Will this only be updated by an admin?

As far as how to accomplish it I would use a custom control with a custom datasource to add the data if it was only going to be added by an admin with designer. If you are going to have an end user complete the data I could think of a few ways to accomplish it with a document/view.

Upvotes: 0

Related Questions