ColdFusion Config Settings
code, design, ColdFusion, CFCHere 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.
Handleing Results in Model-Glue
code, ColdFusion, CFC, model-glueOk I am not the world’s best blogger but I am going to give a shot. So I am working on a Model-Glue Application that I started about a year and a half ago. And I am finally starting to reuse some of my functions. For example I have a saveUserAddress function and a saveUserAccount function and in both of these function’s I add result named success if there wasn’t an error. So here is the problem, we adding a new feature that allows a user to setup a new address and a new account on the same screen but in Model-Glue if there is a result the next function will not be called. So to fix this problem I added an argument to the message in the modelglue.xml file like so.
<message name="SaveUserAddress">
<argument name="addResult" value="false" />
</message>
<message name="SaveUserAccount" />Then in the controller component I add some logic to account for this.
<cfif arguments.event.ArgumentExists("addResult")>
<cfif arguments.event.getValue("addResult") EQ true>
<cfset arguments.event.addResult("success", true) />
</cfif>
</cfif>I know there some Mach-II guys out there so I would like to know how you handle this in Mach-II.
Website Icons
HTML, code, IconsIts really hard to find good free Icons, here are some from webappers.com.
Quick CFC Gotcha
code, ColdFusion, CFCLets say you have a bean for an employee and it has getFirstName and setFirstName and lets you forget to put parenthesis like this
<input type="Text" name="firstname" id="firstname" value="<cfoutput>#employeeBean.getFirstname#</cfoutput>" />
<input type="Text" name="firstname" id="firstname" value="cfemployee2ecfc490364409$funcGETFIRSTNAME@25a2fe" />





Loading....