coldbox rc var not showing up - coldfusion

ColdBox Variable
handlers/home.cfc
<cffunction name="index" output="false" hint="index">
<cfargument name="event">
<cfset rc.Test = 'This is a test 123.' />
<cfset event.setView("home/index")>
</cffunction>
views/home/index.cfm
<cfdump var="#rc#" />
Why is rc.test not showing up in the dump?

Without rc defined with cfargument, your rc.test will be set to variables.rc.test in your handler.
Do this:
<cffunction name="index" output="false" hint="index">
<cfargument name="event">
<cfargument name="rc">
<cfargument name="prc">
<cfset rc.Test = 'This is a test 123.' />
<cfset event.setView("home/index")>
</cffunction>

You need to assign RC to Event.getCollection(). We do this at the top of every handler function.
<cffunction name="index" returntype="void" output="false">
<cfargument name="event" required="true">
<cfscript>
var rc = event.getCollection();
var prc = event.getCollection( private = true );
// your handler code here
Event.setView('home/index');
</cfscript>
</cffunction>

Related

ColdFusion 11 seems to render definitions for superclass as well as class

In a ColdFusion application, I have a class called ProjectBeanService that extends another class called AjaxBeanService.
In CF8, where the code seems to be working properly, when debugging the application in IE, I see this rendered JavaScript:
<script type="text/javascript">
var _cf_ProjectBeanService=ColdFusion.AjaxProxy.init('/components/ProjectBeanService.cfc','ProjectBeanService');
_cf_ProjectBeanService.prototype.get=function(sPropertyName,sBeanType,nID,sSection,nRevision) { return ColdFusion.AjaxProxy.invoke(this, "get", {sPropertyName:sPropertyName,sBeanType:sBeanType,nID:nID,sSection:sSection,nRevision:nRevision});};
_cf_ProjectBeanService.prototype.getAll=function(sBeanType,nID,sSection,nRevision) { return ColdFusion.AjaxProxy.invoke(this, "getAll", {sBeanType:sBeanType,nID:nID,sSection:sSection,nRevision:nRevision});};
_cf_ProjectBeanService.prototype.set=function(sPropertyName,oPropertyValue,sBeanType,nID,sSection,nRevision) { return ColdFusion.AjaxProxy.invoke(this, "set", {sPropertyName:sPropertyName,oPropertyValue:oPropertyValue,sBeanType:sBeanType,nID:nID,sSection:sSection,nRevision:nRevision});};
</script>
However, when I try to run the same application under CF11, both the class methods and the superclass methods are rendered:
<script type="text/javascript">/* <![CDATA[ */
var _cf_ProjectBeanService=ColdFusion.AjaxProxy.init('/components/ProjectBeanService.cfc','ProjectBeanService');
_cf_ProjectBeanService.prototype.get=function(sPropertyName,sBeanType,nID,sSection,nRevision) { return ColdFusion.AjaxProxy.invoke(this, "get","4789898A8974AC60", {sPropertyName:sPropertyName,sBeanType:sBeanType,nID:nID,sSection:sSection,nRevision:nRevision});};
_cf_ProjectBeanService.prototype.getAll=function(sBeanType,nID,sSection,nRevision) { return ColdFusion.AjaxProxy.invoke(this, "getAll","4789898A8974AC60", {sBeanType:sBeanType,nID:nID,sSection:sSection,nRevision:nRevision});};
_cf_ProjectBeanService.prototype.set=function(sPropertyName,oPropertyValue,sBeanType,nID,sSection,nRevision) { return ColdFusion.AjaxProxy.invoke(this, "set","4789898A8974AC60", {sPropertyName:sPropertyName,oPropertyValue:oPropertyValue,sBeanType:sBeanType,nID:nID,sSection:sSection,nRevision:nRevision});};
_cf_ProjectBeanService.prototype.get=function(sBeanName,sPropertyName) { return ColdFusion.AjaxProxy.invoke(this, "get","4789898A8974AC60", {sBeanName:sBeanName,sPropertyName:sPropertyName});};
_cf_ProjectBeanService.prototype.destroySessionBean=function(sBeanName) { return ColdFusion.AjaxProxy.invoke(this, "destroySessionBean","4789898A8974AC60", {sBeanName:sBeanName});};
_cf_ProjectBeanService.prototype.createSessionBean=function(sBeanName,sBeanType,sDAOName) { return ColdFusion.AjaxProxy.invoke(this, "createSessionBean","4789898A8974AC60", {sBeanName:sBeanName,sBeanType:sBeanType,sDAOName:sDAOName});};
_cf_ProjectBeanService.prototype.getAll=function(sBeanName) { return ColdFusion.AjaxProxy.invoke(this, "getAll","4789898A8974AC60", {sBeanName:sBeanName});};
_cf_ProjectBeanService.prototype.getSessionBean=function(sBeanName) { return ColdFusion.AjaxProxy.invoke(this, "getSessionBean","4789898A8974AC60", {sBeanName:sBeanName});};
_cf_ProjectBeanService.prototype.set=function(sBeanName,sPropertyName,oPropertyValue) { return ColdFusion.AjaxProxy.invoke(this, "set","4789898A8974AC60", {sBeanName:sBeanName,sPropertyName:sPropertyName,oPropertyValue:oPropertyValue});};
_cf_ProjectBeanService.prototype.reInitSessionBean=function(sBeanName,argument1,argument2,argument3,argument4) { return ColdFusion.AjaxProxy.invoke(this, "reInitSessionBean","4789898A8974AC60", {sBeanName:sBeanName,argument1:argument1,argument2:argument2,argument3:argument3,argument4:argument4});};
/* ]]> */</script>
In this block of code, notice how after the "set" function is defined, it is defined again (and according to the superclass definition). It seems to me that ColdFusion 11 is rendering this superclass, whereas CF 8 did not.
Any suggestions?
UPDATE:
Here is a stripped down version of the application, wherein I was able to reproduce the error.
/components/AbstractAjax.cfc:
<cfcomponent displayname="AbstractAjax">
<cffunction name="sendError" access="private" returntype="void">
<cfargument name="sErrCode" type="string" required="yes" />
<cfargument name="sErrMsg" type="string" required="yes" />
<cfif IsNumeric(arguments.sErrCode)>
<cfscript>
GetPageContext().getResponse().sendError(arguments.sErrCode,arguments.sErrMsg);
</cfscript>
<cfelse>
<cfscript>
GetPageContext().getResponse().sendError(555,arguments.sErrCode & ' - ' & arguments.sErrMsg);
</cfscript>
</cfif>
</cffunction>
</cfcomponent>
/components/AjaxBeanService.cfc:
<cfcomponent displayname="AjaxBeanService" extends="com.AbstractAjax">
<cffunction name="createSessionBean" access="remote" returntype="struct">
<cfargument name="sBeanName" type="string" required="yes">
<cfargument name="sBeanType" type="string" required="yes">
<cfargument name="sDAOName" type="string" required="yes">
<cfset var oBean = StructNew() />
<cfset var oBeanArguments = ARGUMENTS />
<cfset var oDAO = application[sDAOName] />
<cftry>
<cfset oBean = createObject("component","com." & sBeanType) />
<!--- delete first 3 elements from arguments array --->
<cfset ArrayDeleteAt(oBeanArguments,1) />
<cfset ArrayDeleteAt(oBeanArguments,1) />
<cfset ArrayDeleteAt(oBeanArguments,1) />
<!--- make the DAO object the first argument --->
<cfset ArrayPrepend(oBeanArguments,oDAO) />
<cfset oBean.init.apply(oBean,oBeanArguments) />
<cfset SESSION.beans[sBeanName] = oBean />
<cfreturn oBean.getAll() />
<cfcatch type="any">
<cfset sendError(cfcatch.ErrorCode,cfcatch.message) />
</cfcatch>
</cftry>
</cffunction>
<cffunction name="destroySessionBean" access="remote" returntype="struct">
<cfargument name="sBeanName" type="string" required="yes">
<cfset rc = StructDelete(SESSION.beans, "#sBeanName#", "True")>
</cffunction>
<cffunction name="reInitSessionBean" access="remote" returntype="struct">
<cfargument name="sBeanName" type="string" required="yes">
<cfargument name="argument1" type="any" required="no" default="">
<cfargument name="argument2" type="any" required="no" default="">
<cfargument name="argument3" type="any" required="no" default="">
<cfargument name="argument4" type="any" required="no" default="">
<cfset var oBean = StructNew() />
<cftry>
<cfset oBean = getSessionBean(sBeanName) />
<cfset oBean.init(oBean.getDAO(),argument1,argument2,argument3,argument4) />
<cfset SESSION.beans[sBeanName] = oBean />
<cfreturn oBean.getAll() />
<cfcatch type="any">
<cfset sendError(cfcatch.ErrorCode,cfcatch.message) />
</cfcatch>
</cftry>
</cffunction>
<cffunction name="getSessionBean" access="remote" returntype="any">
<cfargument name="sBeanName" type="string" required="yes">
<cfset var oBean = StructNew() />
<cfif StructKeyExists(SESSION.beans,sBeanName) >
<cflock scope="session" type="readonly" timeout="5" throwontimeout="yes">
<cfset oBean = Duplicate(SESSION.beans[sBeanName]) />
</cflock>
</cfif>
<cfif StructIsEmpty(oBean)>
<cfthrow errorcode="500" message="No bean found by the name '#sBeanname#'" />
<cfelse>
<cfreturn oBean />
</cfif>
</cffunction>
<cffunction name="set" access="remote" returntype="void">
<cfargument name="sBeanName" type="string" required="yes">
<cfargument name="sPropertyName" type="string" required="yes">
<cfargument name="oPropertyValue" type="string" required="yes">
<cfset var oBean = StructNew() />
<cftry>
<cfset oBean = getSessionBean(sBeanName) />
<cfset oBean.set(sPropertyName,oPropertyValue) />
<cfcatch type="any">
<cfset sendError(cfcatch.ErrorCode,cfcatch.message) />
</cfcatch>
</cftry>
</cffunction>
<cffunction name="get" access="remote" returntype="any">
<cfargument name="sBeanName" type="string" required="yes">
<cfargument name="sPropertyName" type="string" required="yes">
<cfset var value = "" />
<cfset var oBean = StructNew() />
<cftry>
<cfset oBean = getSessionBean(sBeanName) />
<cfset value = oBean.get(sPropertyName) />
<cfreturn value />
<cfcatch type="any">
<cfset sendError(cfcatch.ErrorCode,cfcatch.message) />
</cfcatch>
</cftry>
</cffunction>
<cffunction name="getAll" access="remote" returntype="struct">
<cfargument name="sBeanName" type="string" required="yes">
<cfset var oBean = StructNew() />
<cfset var oStruct = structNew() />
<cftry>
<cfset oBean = getSessionBean(sBeanName) />
<cfset oStruct = oBean.getAll() />
<cfreturn oStruct />
<cfcatch type="any">
<cfset sendError(cfcatch.ErrorCode,cfcatch.message) />
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
/components/ProjectBeanService.cfc:
<cfcomponent displayname="ProjectBeanService" extends="com.AjaxBeanService">
<cffunction name="getBean" access="private" returntype="any">
<cfargument name="sBeanType" type="string" required="yes">
<cfargument name="nID" type="numeric" required="yes" hint="ProjectID or ImpactID">
<cfargument name="sSection" type="string" required="no" hint="ProjectSection or ImpactSection" default="">
<cfargument name="nRevision" type="numeric" required="no" hint="Commitment Revision" default="0">
<cfset var oBean = createObject("component","com." & sBeanType).init(nID,sSection,nRevision) />
<cfreturn oBean />
</cffunction>
<cffunction name="set" access="remote" returntype="void">
<cfargument name="sPropertyName" type="string" required="yes">
<cfargument name="oPropertyValue" type="string" required="yes">
<cfargument name="sBeanType" type="string" required="yes">
<cfargument name="nID" type="numeric" required="yes">
<cfargument name="sSection" type="string" required="no" default="">
<cfargument name="nRevision" type="numeric" required="no" default="0">
<cfset var oBean = StructNew() />
<cftry>
<cfset oBean = getBean(sBeanType, nID, sSection,nRevision) />
<cfset oBean.set(sPropertyName,oPropertyValue) />
<cfcatch type="any">
<cfset sendError(cfcatch.ErrorCode,cfcatch.message) />
</cfcatch>
</cftry>
</cffunction>
<cffunction name="get" access="remote" returntype="any">
<cfargument name="sPropertyName" type="string" required="yes">
<cfargument name="sBeanType" type="string" required="yes">
<cfargument name="nID" type="numeric" required="yes">
<cfargument name="sSection" type="string" required="no" default="">
<cfargument name="nRevision" type="numeric" required="no" default="0">
<cfset var value = "" />
<cfset var oBean = StructNew() />
<cftry>
<cfset oBean = getBean(sBeanType,nID,sSection,nRevision) />
<cfset value = oBean.get(sPropertyName) />
<cfreturn value />
<cfcatch type="any">
<cfset sendError(cfcatch.ErrorCode,cfcatch.message) />
</cfcatch>
</cftry>
</cffunction>
<cffunction name="getAll" access="remote" returntype="struct">
<cfargument name="sBeanType" type="string" required="no" default="ProjectBean">
<cfargument name="nID" type="numeric" required="yes">
<cfargument name="sSection" type="string" required="no" default="">
<cfargument name="nRevision" type="numeric" required="no" default="0">
<cfset var oBean = StructNew() />
<cfset var oStruct = structNew() />
<cftry>
<cfset oBean = getBean(sBeanType,nID,sSection,nRevision) />
<cfset oStruct = oBean.getAll() />
<cfreturn oStruct />
<cfcatch type="any">
<cfset sendError(cfcatch.ErrorCode,cfcatch.message) />
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
/Application.cfc:
<cfcomponent>
<cfscript>
this.mappings["/com"] = getDirectoryFromPath(getCurrentTemplatePath()) & "\components\";
</cfscript>
</cfcomponent>
/index.cfm:
<html>
<head>
<title></title>
<cfajaxproxy cfc="com.ProjectBeanService" jsclassname="ProjectBeanService">
</head>
<body>
<span>This is a test.</span>
</body>
</html>
So far, the only answer I have come up with is that this must be a bug in CF11, so I was able to "fix" it by marking the methods in the parent class as having access "public" rather than "remote". I do not yet know what unintended consequences this could have, but it seems to have fixed my problem. If anyone has a better suggestion, please let me know, and I'll give the answer check to that person.

query is not indexable by column name but the columns shouldn't exist

So every so often I am getting this error, mostly caused by bots:
java.lang.IllegalArgumentException:
[Table (rows 0 columns ID, BOOKID, EDITIONID, EDITIONNAME, PRACTICEAREALINK, PUBLISHED):
...REALINK: coldfusion.sql.QueryColumn#2c12f137]
[PUBLISHED: coldfusion.sql.QueryColumn#f9a687c] ] is not indexable by webtypeid
However the columns it refers to are nowhere to be found in the query it's trying to reference.
so we have 3 files in play here, an index.cfm, a Business.cfc and a DAO.cfc. Within the business the code looks like:
<cfcomponent extends="_lbr._core.NativeBusiness">
<cffunction name="init" access="public" output="false" returntype="_lbr._who._publication._Edition.EditionBusiness" hint="Pseudo-constructor">
<cfargument name="oEditionDAO" type="_lbr._who._publication._Edition.EditionDAO" required="true">
<cfscript>
super.init(argumentCollection=arguments);
variables.oEditionDAO = arguments.oEditionDAO;
return this;
</cfscript>
</cffunction>
<cffunction name="getEditionByPracticeArea" returntype="query" access="public">
<cfargument name="nEditionID" type="numeric" required="false">
<cfargument name="nPraciceAreaID" type="numeric" required="false">
<cfargument name="bPublished" type="boolean" required="false">
<cfscript>
return variables.oEditionDAO.getEditionByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
<cffunction name="getEditionsByPracticeArea" returntype="query" access="public">
<cfargument name="nPracticeAreaID" type="numeric" required="false">
<cfargument name="bPracticeAreaLink" type="boolean" required="false">
<cfargument name="bPublished" type="boolean" required="false">
<cfargument name="lstFields" type="string" required="false">
<cfscript>
return variables.oEditionDAO.getEditionsByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
<cffunction name="getTypesByPracticeArea" returntype="query" access="public">
<cfargument name="nPracticeAreaID" type="numeric" required="false">
<cfargument name="nEditionID" type="numeric" required="false">
<cfscript>
return variables.oEditionDAO.getTypesByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
</cfcomponent>
Nothing particularly unusual there.
the DAO looks like
<cfcomponent extends="_lbr._core.NativeDAO">
<cffunction name="init" access="public" output="false" returntype="_lbr._who._Publication._Edition.EditionDAO" hint="Pseudo-constructor">
<cfargument name="sDSN" type="string" required="true" hint="The datasource name to use to access the database through.">
<cfargument name="oCFML" type="_lbr._util._cfml.CFML" required="true" hint="The CFML object to use for scripting.">
<cfscript>
super.init(argumentCollection=arguments);
variables.sDSN = arguments.sDSN;
variables.oCFML = arguments.oCFML;
variables.lstFields = "p.publication_ID, p.publication_name, e.edition_id, e.edition_name, e.pub_year, e.pub_date";
variables.lstSubEditionFields = "id,bookid,editionid,editionname,practiceareaLink,published";
return this;
</cfscript>
</cffunction>
<cffunction name="getEditionByPracticeArea" returntype="query" access="public">
<cfargument name="nEditionID" type="numeric" required="false">
<cfargument name="nPraciceAreaID" type="numeric" required="false">
<cfargument name="bPublished" type="boolean" required="false">
<cfargument name="nStartRow" required="true" type="numeric" default="0">
<cfargument name="nEndRow" required="true" type="numeric" default="1">
<cfscript>
return selectEditionsByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
<cffunction name="getEditionsByPracticeArea" returntype="query" access="public">
<cfargument name="nPracticeAreaID" type="numeric" required="false">
<cfargument name="bPracticeAreaLink" type="boolean" required="false">
<cfargument name="bPublished" type="boolean" required="false">
<cfargument name="lstFields" type="string" required="false">
<cfscript>
return selectEditionsByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
<cffunction name="selectEditionsByPracticeArea" returntype="query" access="public">
<cfargument name="nStartRow" required="true" type="numeric" default="0">
<cfargument name="nEndRow" required="true" type="numeric" default="100">
<cfargument name="nEditionID" type="numeric" required="false" default="0">
<cfargument name="nPracticeAreaID" type="numeric" required="false" default="0">
<cfargument name="bPracticeAreaLink" type="boolean" required="false">
<cfargument name="bPublished" type="boolean" required="false">
<cfargument name="lstFields" type="string" default="#variables.lstSubEditionFields#" required="false">
<cfquery name="qQuery" datasource="#variables.sDSN#">
SELECT #arguments.lstFields#
FROM tbl_who_subeditions
WHERE 1
<cfif arguments.nPracticeAreaID gt 0>
AND bookid = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nPracticeAreaID#">
</cfif>
<cfif arguments.nEditionID gt 0>
AND editionID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nEditionID#">
</cfif>
<cfif structKeyExists(arguments,"bPublished")>
AND published = <cfqueryparam cfsqltype="cf_sql_bit" value="#arguments.bPublished#">
</cfif>
<cfif arguments.nPracticeAreaID gt 0 OR arguments.nEditionID gt 0>
<cfif structKeyExists(arguments,"bPracticeAreaLink")>
AND practiceareaLink = <cfqueryparam cfsqltype="cf_sql_tinyint" value="#arguments.bPracticeAreaLink#">
</cfif>
</cfif>
LIMIT #arguments.nStartRow#,#arguments.nEndRow#
</cfquery>
<cfreturn qQuery>
</cffunction>
<cffunction name="getTypesByPracticeArea" returntype="query" access="public">
<cfargument name="nPracticeAreaID" type="numeric" required="false">
<cfargument name="nEditionID" type="numeric" required="false">
<cfscript>
return selectTypesByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
<cffunction name="selectTypesByPracticeArea" returntype="query" access="public">
<cfargument name="nStartRow" required="true" type="numeric" default="0">
<cfargument name="nEndRow" required="true" type="numeric" default="100">
<cfargument name="nEditionID" type="numeric" required="false" default="0">
<cfargument name="nPracticeAreaID" type="numeric" required="false" default="0">
<cfargument name="lstFields" type="string" default="#variables.lstSubEditionFields#" required="false">
<cfquery name="qQuery" datasource="#variables.sDSN#">
SELECT distinct webtypeid, typename
FROM tbl_who_webtype2practiceareas wp
JOIN tbl_who_webtypes w ON wp.webtypeid = w.id
WHERE 1
<cfif arguments.nPracticeAreaID gt 0>
AND bookid = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nPracticeAreaID#">
</cfif>
<cfif arguments.nEditionID gt 0>
AND editionid = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nEditionID#">
</cfif>
LIMIT #arguments.nStartRow#,#arguments.nEndRow#
</cfquery>
<cfreturn qQuery>
</cffunction>
</cfcomponent>
The only thing that is unusual here is that selectTypesByPracticeArea has a lstFields defaulted with variables.lstSubEditionFields, but since it's not being used in that function, it shouldn't prove an issue
so the index.cfm just has
variables.stArgs = {};
variables.stArgs.nPracticeAreaID = request.parameters.nPublicationID;
variables.stArgs.nEditionID = request.parameters.nSubEdition;
variables.qTypes = application.stObj.oEditionBusiness.getTypesByPracticeArea(argumentCollection=variables.stArgs);
if(variables.qTypes["webtypeid"].IndexOf(JavaCast("int",2)) GTE 0 OR variables.qTypes["webtypeid"].IndexOf(JavaCast("int",3)) GTE 0){
request.parameters.bHasTypes = true;
}
The error occurs on that if statement. It should only be receiving a query that contains webtypeid and typename, so where does it think that it's getting ID, BOOKID, EDITIONID, EDITIONNAME, PRACTICEAREALINK, PUBLISHED from? All i can reason is that it's getting confused with the lstfields... but that doesn't make any sense.
At first glance I suspect it's that you are not using var to declare qQuery local to the function, so it is being overwritten at times while you are executing these methods. If you try this before your CFQUERY tags you will likely see it go away:
<cfset var qQuery = "">
You can also use the LOCAL scope as in local.qQuery

how to pass the data of the function to a custom tag attribute

My Custom tag expects a “query” in one of the attribute but my cfc function returns me the structure when I dump it. This is my function listScores()
<cffunction name="listScores" access="public" output="false" returntype="any"> <!--- not really scores, should probably rename this function - something to consider --->
<cfargument name="link" type="string" required="false" />
<cfargument name="linktype" type="numeric" required="false" default="2" /> <!--- 2 = ace inspection -> ace action--->
<cfargument name="reftype" type="numeric" required="false" default="2" /> <!--- 2 = equipment --->
<cfargument name="siteid" type="numeric" required="false" />
<cfargument name="archived" type="numeric" required="false" default="0" /> <!--- 0 = not archived --->
<cfargument name="acerefid" type="numeric" required="false" hint="ace_links refid" />
<cfargument name="apprefid" type="numeric" required="false" hint="equip tracker refid" />
<cfargument name="responseType" type="string" require="false" />
<cfif structKeyExists(arguments,'responseType') && arguments.responseType is 'query'>
<cfreturn OCRUD.listScores(argumentCollection=arguments) />
</cfif>
<cfreturn getArrayFromQuery(OCRUD.listScores(argumentCollection=arguments)) />
</cffunction>
When i dump the iEngine.listScores() i get the structure output.
I want to pass this iEngine.listScores() data to the custom tag which expects a query.
<cfmodule template="#request.library.customtags.virtualpath#excel.cfm" file="#filename#" sheetname="ACE Report">
<cfmodule template="#request.library.customtags.virtualpath#exceldata.cfm"
query="#variables.qlistScoreData#"
action="AddWorksheet"
sheetname="ACE Report"
colorscheme="blue"
useheaders="true"
contentformat="#{bold=true}#"
<!--- customheaders="#ListScore#" --->
>
<cfoutput>Excel Extract - ACE Report - #DateFormat(Now(),"d-mmm-yyyy")#</cfoutput>
</cfmodule>
</cfmodule>

How to reference a returned structure from a cfc?

I'm using the validation CFC by Ryan J. Heldt http://validation.riaforge.org/
My form submits to processSignup.cfc
<cfscript>
objValidation = createObject("component","cfcs.validation").init();
objValidation.setFields(form);
objValidation.validate();
</cfscript>
<!--- clear the error/success message --->
<cfset msg="">
<cfif objValidation.getErrorCount() is not 0>
<cfsavecontent variable="msg">
<H2>Error in form submission</H2>
<P>There were <cfoutput>#objValidation.getErrorCount()#</cfoutput> errors in your submission:</P>
<ul>
<cfloop collection="#variables.objValidation.getMessages()#" item="rr">
<li><cfoutput>#variables.objValidation.getMessage(rr)#</cfoutput></li>
</cfloop>
</ul>
<p>Please use the back button on your browser to correct your submission.</p>
</cfsavecontent>
</cfif>
<cfdump var="#objvalidation#">
<cfoutput>
#msg#
</cfoutput>
Which gives me this output
What I'm trying figure out is the name of the structure and how to to get to "confirm password", "password", "username" but I'm being dense and I can't figure out how to.
<!---
<fusedoc fuse="Validation.cfc" language="ColdFusion" specification="2.0">
<responsibilities>
I am a ColdFusion Component that performs server-side form validation.
Copyright 2006-2008 Ryan J. Heldt. All rights reserved.
Validation.cfc is licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain
a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License.
If you use this component in a live site, I would love to know where! Please end
me a quick note at rheldt#ryanheldt.com with the name of the site the URL.
</responsibilities>
<property name="version" value="1.00" />
<property name="copyright" value="Copyright 2006-2008 Ryan J. Heldt." />
</properties>
</fusedoc>
--->
<cfcomponent displayname="Validation" hint="ColdFusion component that performs server-side form validation." output="false">
<!--- ---------- Properties ---------- --->
<cfproperty name="fields" type="struct" />
<cfproperty name="directories" type="struct" />
<cfproperty name="files" type="struct" />
<cfproperty name="errors" type="numeric" />
<cfproperty name="messages" type="struct" />
<cfproperty name="mimeTypes" type="array" />
<!--- ---------- Constructors ---------- --->
<cffunction name="init" access="public" output="false" returntype="Validation">
<cfscript>
_fields = structNew();
_directories = structNew();
_files = structNew();
_uploadedFiles = structNew();
_errors = 0;
_messages = structNew();
_cardTypes = structNew();
_mimeTypes = arrayNew(1);
</cfscript>
<cfreturn this />
</cffunction>
<!--- ---------- Accessors and Mutators ---------- --->
<cffunction name="getFields" access="public" output="false" returntype="struct">
<cfreturn _fields />
</cffunction>
<cffunction name="setFields" access="public" output="false" returntype="void">
<cfargument name="fields" type="struct" required="true" />
<cfset _fields = arguments.fields />
<cfreturn />
</cffunction>
<cffunction name="getDirectories" access="public" output="false" returntype="struct">
<cfreturn _directories />
</cffunction>
<cffunction name="setDirectories" access="public" output="false" returntype="void">
<cfargument name="directories" type="struct" required="true" />
<cfset _directories = arguments.directories />
<cfreturn />
</cffunction>
<cffunction name="getFiles" access="public" output="false" returntype="struct">
<cfreturn _files />
</cffunction>
<cffunction name="getErrorCount" access="public" output="false" returntype="numeric">
<cfreturn _errors />
</cffunction>
<cffunction name="getMessages" access="public" output="false" returntype="struct">
<cfreturn _messages />
</cffunction>
<cffunction name="getMessage" access="public" output="false" returntype="string">
<cfargument name="field" type="string" required="true" />
<cfif structKeyExists(_messages,field)>
<cfreturn _messages[field] />
<cfelse>
<cfreturn "" />
</cfif>
</cffunction>
<cffunction name="getCardType" access="public" output="false" returntype="string">
<cfargument name="field" type="string" required="true" />
<cfif structKeyExists(_cardTypes,field)>
<cfreturn _cardTypes[field] />
<cfelse>
<cfreturn "" />
</cfif>
</cffunction>
<cffunction name="getMimeTypes" access="public" output="false" returntype="array">
<cfreturn _mimeTypes />
</cffunction>
<!--- ---------- Public Methods ---------- --->
<cffunction name="validate" access="public" output="true" returntype="void">
<cfset var rr = 0 />
<cfloop list="#structKeyList(_fields)#" index="rr">
<cfif lCase(left(rr,9)) is "validate_">
<cfswitch expression="#lCase(rr)#">
<cfcase value="validate_require">
<!--- Required Fields --->
<cfset validateRequired(_fields[rr]) />
</cfcase>
<cfcase value="validate_integer">
<!--- Validate Integers --->
<cfset validateInteger(_fields[rr]) />
</cfcase>
<cfcase value="validate_numeric">
<!--- Validate Numeric --->
<cfset validateNumeric(_fields[rr]) />
</cfcase>
<cfcase value="validate_email">
<!--- Validate E-mail Addresses --->
<cfset validateEmail(_fields[rr]) />
</cfcase>
<cfcase value="validate_url">
<!--- Validate URLs --->
<cfset validateURL(_fields[rr]) />
</cfcase>
<cfcase value="validate_ip">
<!--- Validate IP Addresses --->
<cfset validateIP(_fields[rr]) />
</cfcase>
<cfcase value="validate_ssn">
<!--- Validate Socical Security Number (United States) nnn-nn-nnnn --->
<cfset validateSSN(_fields[rr]) />
</cfcase>
<cfcase value="validate_postal">
<!--- Validate Postal Code (United States and Canada) nnnnn or nnnnn-nnnn or ana-nan --->
<cfset validatePostal(_fields[rr]) />
</cfcase>
<cfcase value="validate_dateus">
<!--- Validate Date (United States) mm/dd/yyyy --->
<cfset validateDateUS(_fields[rr]) />
</cfcase>
<cfcase value="validate_dateeu">
<!--- Validate Date (Europe) dd/mm/yyyy --->
<cfset validateDateEU(_fields[rr]) />
</cfcase>
<cfcase value="validate_time">
<!--- Validate Time hh:mm:ss tt --->
<cfset validateDateEU(_fields[rr]) />
</cfcase>
<cfcase value="validate_phoneus">
<!--- Validate Phone Number (United States) nnn-nnn-nnnn --->
<cfset validatePhoneUS(_fields[rr]) />
</cfcase>
<cfcase value="validate_currencyus">
<!--- Validate Currency (United States) Allows optional "$", optional "-" or "()" but not both, optional cents, and optional commas separating thousands --->
<cfset validateCurrencyUS(_fields[rr]) />
</cfcase>
<cfcase value="validate_creditcard">
<!--- Validate Credit Card using Luhn Algorithm --->
<cfset validateCreditCard(_fields[rr]) />
</cfcase>
<cfcase value="validate_password">
<!--- Validate two fields to make sure they match. Comparison is case-sensitive --->
<cfset validatePassword(_fields[rr]) />
</cfcase>
<cfcase value="validate_file">
<!--- Upload files and validate their MIME types --->
<cfset loadMimeTypes() />
<cfset validateFile(_fields[rr]) />
</cfcase>
</cfswitch>
</cfif>
</cfloop>
<cfif val(_errors)>
<!--- If there were any validation errors, delete all the upload files --->
<cfset cleanupFiles() />
</cfif>
<cfreturn />
</cffunction>
<!--- ---------- Package Methods ---------- --->
<cffunction name="validateRequired" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif not (isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]))>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateInteger" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not reFind("^-?\d+$",_fields[listGetAt(rr,1,"|")])>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateNumeric" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not isNumeric(_fields[listGetAt(rr,1,"|")])>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateEmail" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not reFind("^[a-zA-Z][\w\.-]*[a-zA-Z0-9]#[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$",_fields[listGetAt(rr,1,"|")])>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateURL" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not reFind("https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?",_fields[listGetAt(rr,1,"|")])>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateIP" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not reFind("\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b",_fields[listGetAt(rr,1,"|")])>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateSSN" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not reFind("^\d{3}-\d{2}-\d{4}$",_fields[listGetAt(rr,1,"|")])>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validatePostal" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not reFind("^((\d{5}-\d{4})|(\d{5})|([A-Z]\d[A-Z]\s\d[A-Z]\d))$",_fields[listGetAt(rr,1,"|")])>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateDateUS" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not (reFind("(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d",_fields[listGetAt(rr,1,"|")]) and isDate(_fields[listGetAt(rr,1,"|")]))>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateDateEU" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not (reFind("(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d",_fields[listGetAt(rr,1,"|")]) and isDate(_fields[listGetAt(rr,1,"|")]))>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateTime" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not (reFind("^((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))$|^([01]\d|2[0-3])",uCase(_fields[listGetAt(rr,1,"|")])) and isDate(_fields[listGetAt(rr,1,"|")]))>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validatePhoneUS" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not reFind("^[2-9]\d{2}-\d{3}-\d{4}$",_fields[listGetAt(rr,1,"|")])>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateCurrencyUS" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and len(_fields[listGetAt(rr,1,"|")]) and not reFind("^\$?\-?([1-9]{1}[0-9]{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\-?\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\(\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))\)$",_fields[listGetAt(rr,1,"|")])>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateCreditCard" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<!--- Based on isCreditCard() by Nick de Voil (cflib.org/udf.cfm?id=49) --->
<cfset var strCardNumber = "" />
<cfset var strProcessedNumber = "" />
<cfset var intCalculatedNumber = 0 />
<cfset var isValid = false />
<cfset var rr = 0 />
<cfset var i = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfscript>
// Take out spaces and dashes. Flip card number around for processing
strCardNumber = replace(_fields[listGetAt(rr,1,"|")]," ","","all");
strCardNumber = replace(strCardNumber,"-","","all");
strCardNumber = reverse(strCardNumber);
_cardTypes[listGetAt(rr,1,"|")] = "Unknown";
// Double every other digit
if (isNumeric(strCardNumber) and len(strCardNumber) gt 12) {
for(i = 1; i lte len(strCardNumber); i = i + 1) {
if(i mod 2 is 0) {
strProcessedNumber = strProcessedNumber & mid(strCardNumber,i,1) * 2;
} else {
strProcessedNumber = strProcessedNumber & mid(strCardNumber,i,1);
}
}
// Sum processed digits
for(i = 1; i lte len(strProcessedNumber); i = i + 1) {
intCalculatedNumber = intCalculatedNumber + val(mid(strProcessedNumber,i,1));
}
// See if calculated number passed mod 10 test and attempt to determine card type
if(intCalculatedNumber neq 0 and intCalculatedNumber mod 10 is 0) {
isValid = true;
strCardNumber = reverse(strCardNumber);
if ((len(strCardNumber) eq 15) and (((left(strCardNumber,2) is "34")) or ((left(strCardNumber,2) is "37")))) {
_cardTypes[listGetAt(rr,1,"|")] = "Amex";
}
if ((len(strCardNumber) eq 14) and (((left(strCardNumber,3) gte 300) and (left(strCardNumber,3) lte 305)) or (left(strCardNumber,2) is "36") or (left(strCardNumber, 2) is "38"))){
_cardTypes[listGetAt(rr,1,"|")] = "Diners";
}
if ((len(strCardNumber) eq 16) and (left(strCardNumber,4) is "6011")) {
_cardTypes[listGetAt(rr,1,"|")] = "Discover";
}
if ((len(strCardNumber) eq 16) and (left(strCardNumber,2) gte 51) and (left(strCardNumber,2) lte 55)) {
_cardTypes[listGetAt(rr,1,"|")] = "MasterCard";
}
if (((len(strCardNumber) eq 13) or (len(strCardNumber) eq 16)) and (Left(strCardNumber,1) is "4")) {
_cardTypes[listGetAt(rr,1,"|")] = "Visa";
}
}
}
// Not a valid card number
if (not isValid) {
registerError(listGetAt(rr,1,"|"),listGetAt(rr,2,"|"));
}
</cfscript>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validatePassword" returntype="void" access="private" output="false">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cfif isDefined("#listGetAt(rr,1,"|")#") and isDefined("#listGetAt(rr,2,"|")#") and compare(_fields[listGetAt(rr,1,"|")],_fields[listGetAt(rr,2,"|")]) neq 0>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,3,"|")) />
</cfif>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="validateFile" returntype="void" access="private" output="true">
<cfargument name="parameters" type="string" required="true" />
<cfset var rr = 0 />
<cfset var strCurrentMimeType = "" />
<cfset var strCurrentFileExt = "" />
<cfset var aryValidFileExts = arrayNew(1) />
<cfset var strFilename = "" />
<cfset var blnValidFile = false />
<cfloop index="rr" list="#arguments.parameters#" delimiters=";">
<cftry>
<!--- Perform the upload --->
<cfif structKeyExists(_directories,"#listGetAt(rr,1,"|")#")>
<cfif len(evaluate("#listGetAt(rr,1,"|")#"))>
<cffile action="upload" filefield="#listGetAt(rr,1,"|")#" destination="#_directories[listGetAt(rr,1,"|")]#" nameconflict="makeunique" />
<cfset strCurrentMimeType = "#cffile.contentType#/#cffile.contentSubType#" />
<cfset strCurrentFileExt = "" />
<cfset aryValidFileExts = arrayNew(1) />
<cfset blnValidFile = false />
<!--- Determine file ext from MIME type --->
<cfloop from="1" to="#arrayLen(_mimeTypes)#" index="i">
<cfparam name="_mimeTypes[i]" default="0,0" />
<cfif listGetAt(_mimeTypes[i],2) is strCurrentMimeType>
<cfset strCurrentFileExt = "." & listGetAt(_mimeTypes[i],1) />
</cfif>
</cfloop>
<!--- Look what the server returned if unable to determine from MIME type --->
<cfif not len(strCurrentFileExt)>
<cfset strCurrentFileExt = "." & cffile.serverFileExt />
</cfif>
<!--- Rename the file and register in case we have to clean house--->
<cfset strFilename = "#generateFilename(cffile.clientFilename)##strCurrentFileExt#" />
<cffile action="rename" source="#cffile.serverDirectory#/#cffile.serverFile#" destination="#strFilename#" />
<cfset structInsert(_files,listGetAt(rr,1,"|"),strFilename)>
<cfset structInsert(_uploadedFiles,listGetAt(rr,1,"|"),#cffile.serverDirectory#&"/"&strFilename)>
<!--- Validate file type --->
<cfif listGetAt(rr,2,"|") neq "*">
<cfset aryValidFileExts = listToArray(listGetAt(rr,2,"|")) />
<cfloop from="1" to="#arrayLen(aryValidFileExts)#" index="i">
<cfif replaceNoCase(strCurrentFileExt,".","","all") is aryValidFileExts[i]>
<cfset blnValidFile = true />
</cfif>
</cfloop>
</cfif>
<cfif not blnValidFile>
<cfset registerError(listGetAt(rr,1,"|"),listGetAt(rr,3,"|")) />
</cfif>
</cfif>
<cfelse>
<!--- Developer didn't tell us the upload directory --->
<cfset registerError(listGetAt(rr,1,"|"),"There was no upload directory specified.") />
</cfif>
<cfcatch>
<cfset registerError(listGetAt(rr,1,"|"),"There was as problem uploading a file. Please contact the web site administrator. [#cfcatch.message# #cfcatch.detail#]") />
</cfcatch>
</cftry>
</cfloop>
<cfreturn />
</cffunction>
<cffunction name="registerError" returntype="void" access="private" output="false">
<cfargument name="field" type="string" required="true" />
<cfargument name="message" type="string" required="true" />
<cfset _errors = _errors + 1 />
<cfset _messages[field] = message />
<cfreturn />
</cffunction>
<cffunction name="generateFilename" returntype="string" access="private" output="false">
<cfargument name="originalFilename" type="string" required="true" />
<cfset var rr = 0 />
<cfset var strReturn="" />
<cfset var intCurrentCharacter=0 />
<cfset arguments.originalFilename=trim(lCase(arguments.originalFilename)) />
<cfloop index="rr" from="1" to="#len(arguments.originalFilename)#">
<cfset intCurrentCharacter=asc(mid(arguments.originalFilename,rr,1)) />
<cfif intCurrentCharacter is 32>
<!--- Space --->
<cfset strReturn=strReturn&"_" />
<cfelseif intCurrentCharacter gte 48 and intCurrentCharacter lte 57>
<!--- Numbers 0-9 --->
<cfset strReturn=strReturn&chr(intCurrentCharacter) />
<cfelseif (intCurrentCharacter gte 97 and intCurrentCharacter lte 122)>
<!--- Letters a-z --->
<cfset strReturn=strReturn&chr(intCurrentCharacter) />
<cfelse>
<!--- Skip Everything Else--->
</cfif>
</cfloop>
<cfif len(strReturn)>
<cfset strReturn = lCase(left(strReturn,35)) & "_" />
<cfelse>
<cfset strReturn = "untitled_" />
</cfif>
<cfreturn strReturn & dateFormat(now(),"yyyymmdd") & timeFormat(now(),"HHmmss") />
</cffunction>
<cffunction name="cleanupFiles" returntype="void" access="private" output="false">
<cfset var rr = "" />
<cfloop collection="#_uploadedFiles#" item="rr">
<cfif fileExists(structFind(_uploadedFiles,rr))>
<cffile action="delete" file="#structFind(_uploadedFiles,rr)#" />
</cfif>
</cfloop>
</cffunction>
<cffunction name="loadMimeTypes" returntype="void" access="private" output="false">
<cfscript>
// Microsoft Office Formats (Office 2003 and Prior)
_mimeTypes[1]="doc,application/msword";
_mimeTypes[2]="doc,application/vnd.ms-word";
_mimeTypes[3]="mdb,application/msaccess";
_mimeTypes[4]="mdb,application/vnd.ms-access";
_mimeTypes[5]="mpp,application/msproject";
_mimeTypes[6]="mpp,application/vnd.ms-project";
_mimeTypes[7]="one,application/msonenote";
_mimeTypes[8]="one,application/vnd.ms-onenote";
_mimeTypes[9]="ppt,application/mspowerpoint";
_mimeTypes[10]="ppt,application/vnd.ms-powerpoint";
_mimeTypes[11]="pub,application/mspublisher";
_mimeTypes[12]="pub,application/vnd.ms-publisher";
_mimeTypes[13]="xls,application/msexcel";
_mimeTypes[14]="xls,application/vnd.ms-excel";
// Microsoft Office Formats (Office 2007)
_mimeTypes[15]="docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document";
_mimeTypes[16]="pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation";
_mimeTypes[17]="xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
// Other Document Formats
_mimeTypes[18]="csv,text/csv";
_mimeTypes[19]="csv,text/comma-seperated-values";
_mimeTypes[20]="htm,text/html";
_mimeTypes[21]="pdf,application/pdf";
_mimeTypes[22]="rtf,application/rtf";
_mimeTypes[23]="rtf,text/rtf";
_mimeTypes[24]="txt,text/plain";
_mimeTypes[25]="xml,text/xml";
// Bitmap Image Formats
_mimeTypes[26]="bmp,image/bmp";
_mimeTypes[27]="gif,image/gif";
_mimeTypes[28]="jpg,image/jpeg";
_mimeTypes[29]="jpg,image/pjpeg";
_mimeTypes[30]="png,image/png";
_mimeTypes[31]="png,image/x-png";
_mimeTypes[32]="tif,image/tiff";
// Vector Image Formats
_mimeTypes[33]="ai,application/postscript";
_mimeTypes[34]="swf,application/x-shockwave-flash";
_mimeTypes[35]="svg,image/svg+xml";
// Video Formats
_mimeTypes[36]="avi,video/x-msvideo";
_mimeTypes[37]="mov,video/quicktime";
_mimeTypes[38]="mpg,video/mpeg";
_mimeTypes[39]="wmv,video/x-ms-wmv";
// Audio Formats
_mimeTypes[40]="au,audio/basic";
_mimeTypes[41]="mid,audio/midi";
_mimeTypes[42]="mp3,audio/mpeg";
_mimeTypes[43]="ogg,application/ogg";
_mimeTypes[44]="wav,audio/x-wav";
// Other Formats
_mimeTypes[45]="zip,application/zip";
</cfscript>
<cfreturn />
</cffunction>
</cfcomponent>
I'd think that since <cfdump var="#objvalidation#"> shows you the struct, you'd reference it via objValidation, no?
objValidation.messages should then show you the struct of the messages. Because "Confirm password" is a key with a space in it, you'll need to use array notation to reference it.
So...
#objValidation.messages[ 'Confirm password' ]#
#objValidation.messages[ 'password' ]#
#objValidation.messages[ 'username' ]#
...should work. In theory :)
EDIT: disregard the info above. You're dumping an actual object, not just a struct... so try:
<cfdump var="#objValidation.getMessages()#" />
Look at the code for the CFC and you'll see a getMessage() method which returns a struct. So once you have that, you can get at the individual messages. Since you won't necessarily know what keys exist in the struct (as I assume it will vary depending on the validation failures), I'd just loop over the struct returned from #objValidation.getMessages()# via a standard struct-based <cfloop>
EDIT AGAIN:
<cfloop collection="#objValidation.getMessages()#" item="error">
#error#: #objValidation.getMessages[ error ]#<br />
</cfloop>
If you're trying to get the values, it looks like they're in objValidation.fields:
objValidation.getField('Confirm password')
objValidation.getField('password')
objValidation.getField('username')
I'd recommend making your life easier and taking the space out of the "Confirm password" field.

Why does the dependency injection fail in my CF factory object?

I get this error
Element INSTANCE is undefined in VARIABLES.
I do not see the reason for the error!
This is my factory
<cfcomponent output="true" displayname="ObjectFactory">
<cffunction name="init" access="public" output="true" returntype="ObjectFactory">
<cfset variables.instance = structNew() />
<cfreturn this />
</cffunction>
<cffunction name="createObj" access="public" output="false" returntype="any">
<cfargument name="objName" type="string" required="true" />
<cfswitch expression="#arguments.objName#">
<cfcase value="abstractCollection">
<cfreturn createObject('component',"AbstractCollection").init() />
<cfbreak />
</cfcase>
<cfcase value="assignmentCollection">
<cfreturn createObject('component',"AssignmentCollection").init() />
<cfbreak />
</cfcase>
<cfcase value="salesmanBean">
<cfreturn createObject('component',"SalesmanBean").init(
salesmanHasThisDecorations = this.getInstance("assignmentCollection")) />
<cfbreak />
</cfcase>
</cfswitch>
</cffunction>
<cffunction name="getInstance" access="public" output="false" returntype="any">
<cfargument name="objName" type="string" required="true" />
<!--- Error occurs in the line below --->
<cfif not structKeyExists(variables.instance, arguments.objName)>
<cfset variables.instance[arguments.objName] = this.createObj(arguments.objName) />
</cfif>
<cfreturn variables.instance[arguments.objName] />
</cffunction>
</cfcomponent>
Make sure you call init() when you instantiate ObjectFactory:
<cfset objectFactory = CreateObject("component","ObjectFactory").init()>
FYI, init() and <cfcomponent> should have output='false'
FYI, you should call your own function without "this.", because if for some reason the function is later declared as private, it won't find it in 'this' scope.
Agree that you are likely not calling .init() so are not creating the variable before accessing it.
You also may want to initialize (create) the VARIABLES scoped variables outside of init(). The init() should be used more for passing in values to your internal CFC-scope (VARIABLES scope) than for creating variables within it.
<cfcomponent displayname="ObjectFactory">
<cfset variables.instance = structNew() />
<cffunction name="init" access="public" returntype="ObjectFactory">
<cfargument name="name" required="yes" type="string">
<cfset variables.instance.name = arguments.name>
<cfreturn this />
</cffunction>
...