hub.eb?material_id=430&track_id=431

Loading a Properties File


A properties file provides a way to define properties that can be extracted in scripts. A properties file can be accessed in script in two ways:

  • system.loadPropertiesFromClasspath(propertiesFileName)
  • system.loadPropertiesFromFile(propertiesFilePath)

For example:

var props = system.loadPropertiesFromFile(filePath);
var myProp = props.myProperty;

 

Steps


1

Create a new properties file in your classpath (WEB-INF/classes) called myProperties.properties and paste the following:

# Properties set to be used across the web application
applicationName=myWebApplication

 

2

Create a form called propertiesForm and add a Text Control called title.

3

Attach a before page script and paste the following code:

var props = system.loadPropertiesFromClasspath("myProperties.properties");
controls.title.text.setText(props.applicationName);
4

Run the form and notice that the title is set to myApplication.

Current Module

Related