1
votes

I want to access the value of an entry I have made in a properties file

e.g. the file is called datasource.properties the entry is called DB_FILEPATH and the value is mydatadb.nsf

In SSJS I would collect the value via datasource.getString('KEY') so datasource.getString('DB_FILEPATH')

To run SSJS from CSJS I normally use something like:

var isMobile = '#{javascript:return deviceBean.isMobile()}';

but if I try somthing like:

var db = "#{javascript:return datasource.getString('DB_FILEPATH')}";

I get the error message:

Error while executing JavaScript action expression Script interpreter error, line=1, col=19: [ReferenceError] 'datasource' not found

How should I access the properties file via CSJS?

1

1 Answers

2
votes

Define your "datasource" as resource:

<xp:this.resources>
    <xp:bundle src="/datasource.properties" var="datasource"></xp:bundle>
</xp:this.resources>

and access entries with

var db = "#{javascript: datasource['DB_FILEPATH']}";