Property Files
If you're touching Java, there's probably some property files in your future. We've included the PropertyFile module in CommandBox that you can call directly from CFML. There are also some commands so you can script the creation and updating of property files from the command line and CommandBox recipes.

From the CLI

1
propertyFile show foo.properties
2
propertyFile set propertyFilePath=foo.properties newProp=newValue
3
propertyFile clear foo.properties newProp
Copied!

From CFML

1
// Create and load property file object
2
propertyFile( 'myFile.properties' )
3
.set( 'my.new.property', 'my value' )
4
.store();
5
6
// Get a property
7
var value = propertyFile( 'myFile.properties' )
8
.get( 'existing.property' );
9
10
// Create one from scratch
11
propertyFile()
12
.set( 'brad', 'wood' )
13
.store( 'myFile.properties' );
Copied!
A propertyFile CFC instance can also be treated as a struct as it stores the properties in its this scope.
1
// Create object
2
var propFile = propertyFile( 'myFile.properties' );
3
4
// Access proeprties
5
print.line( propFile.brad );
6
7
// Change/add properties
8
propFile.foobar = true;
9
propFile[ 'another.new.property' ] = false;
10
11
// Save it
12
propFile.store();
Copied!
Copy link