+1

ColdFusion Config Settings

code, design, ColdFusion, CFC

Here is the problem I needed to come up with a way to allow my client admins to set alias's for entry forms and report headers. So I started looking at localization and quickly found that, that was not a good Idea at all so then I started looking at using ini files since ColdFusion has functions for reading and setting config keys. I also found that I didn't like using the config file for this so I created a table to store the infromation. Then I decided to do some test to see if the was some benefit to using a DB verses the ini file low and behold there is.
This code block took [58ms] to run

<cftimer label="iniSettings" type="debug">
	<cfscript>
		iniFile = expandPath('config_1234_12.ini.cfm');
		clientStruct  ={
			clientNameLabel = getProfileString(iniFile, "client", 'clientNameLabel'),
			clientNameHasValidation = getProfileString(iniFile, "client", 'clientNameHasValidation'),
			clientNameValidation = getProfileString(iniFile, "client", 'clientNameValidation')
		};
	</cfscript>
	<cfoutput>
		<label>#clientStruct['clientNameLabel']#</label>
		<input type="input" name="clientName">
		<input type="button" value="Click Me!" onclick="validate()">
		<script>
			function validate(){
				<cfif IsBoolean(clientStruct["clientNameHasValidation"]) AND clientStruct["clientNameHasValidation"] is true>
					#ReReplaceNoCase(clientStruct["clientNameValidation"],'~clientname~', clientStruct["clientNameLabel"])#
				</cfif>
			}
		</script>
	
	</cfoutput>
</cftimer>

 

 

This code block took [2ms] to run

<cftimer label="DBSettings" type="debug">
	<cfscript>
		args = {
		 cfSection = "client"
		};
		
		clientStruct=application.configSettingsService.queryToPropStruct(application.configSettingsService.getByAttributesQuery(argumentcollection=args));
		if(StructKeyExists(clientStruct,'')){
		
		}
	</cfscript>
	<cfoutput>
		<label>#clientStruct['clientNameLabel']#</label>
		<input type="input" name="clientName">
		<input type="button" value="Click Me!" onclick="validate()">
		<script>
			function validate(){
				<cfif IsBoolean(clientStruct["clientNameHasValidation"]) AND clientStruct["clientNameHasValidation"] is true>
					#ReReplaceNoCase(clientStruct["clientNameValidation"],'~clientname~', clientStruct["clientNameLabel"])#
				</cfif>
			}
		</script>
	
	</cfoutput>
</cftimer>

I know 58ms doesn't seem like much but remeber in this example its only one field and I have pages the have 50 fields that a client might alias.


Search

Matt  Graf
View Matt Graf's profile on LinkedIn