Get and set application property values

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Dave
Ebase Staff
Posts: 89
Joined: Mon Sep 10, 2007 11:48 am

Get and set application property values

#1

Postby Dave » Mon Apr 08, 2013 5:25 pm

Sample uses a database table to create, get and set application property name/value pairs. Download here:

http://www.ebaseftp.com/download/sample ... 13_gsp.zip

Sample courtesy of Ian Bramford.
Last edited by Dave on Thu Apr 11, 2013 4:41 pm, edited 1 time in total.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Tue Apr 09, 2013 10:05 am

You can also use a conventional properties file to hold application properties consisting of key/value pairs. Here's an example:

I have a property file called sysAdmin.properties. This should be located anywhere on the server's classpath, in my case in UfsServer/tomcat/webapps/ufs/WEB-INF/classes. The file content looks like this:

# sysAdmin.roles: comma delimited list of roles which allow access to the system administration app
sysAdmin.roles=SUPER_USER
# sysAdmin.users: comma delimited list of users which allow access to the system administration app
sysAdmin.users=user1,user2


Here's a script to read the sysAdmin.roles property:

Code: Select all

var propertyFileName = "sysAdmin";
var propertyName = "sysAdmin.roles";
var propertyValue = getStringProperty(propertyFileName, propertyName);
	
/**
 * Read a string property from a properties file
 */ 
function getStringProperty(propertyFileName, propertyName)
{
	var props = java.util.PropertyResourceBundle.getBundle(propertyFileName);
	if (props)
	{
		return props.getString(propertyName);
	}
	return null;
}
0 x


Who is online

Users browsing this forum: No registered users and 19 guests