---------------------------------------------------------------Original Message-----
From: Bill Rawlinson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 15, 2005 12:31 PM
To: [email protected]
Subject: Re: [CFCDev] Re: Wierd Problem Need Help: Query-> Struct -> argumentCollection
thanks - i had actually only started using the "#varname#" stuff when I couldn't figure out that I was forgetting to specify the rownumberthe cfdump was not helping me at all. And, in fact, when I passed the struct through before and did a test like isNumeric(arguments.id), within the component, it returned true (even though it wasn't).Another wierd caveat was that if I just set all of my arguments types to any everything worked fine - my setXvariable(arguments.xVariable) function worked fine (even though setXVariable expected a numeric or string type).It seems that even though I was screwing up I also found some kind of bug in CF.However, when I did the same test before passing the struct to the component it failed - I was only able to figure out how stupid I was being thanks to getMetaData.Bill
On 6/15/05, Roland Collins <[EMAIL PROTECTED]> wrote:----------------------------------------------------------Save yourself some quotes and # signs! Your code will look cleaner like this:
<cfset y[columnName] = x[columnName][1] />
Roland
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Bill Rawlinson
Sent: Wednesday, June 15, 2005 10:39 AM
To: [email protected]
Subject: [CFCDev] Re: Wierd Problem Need Help: Query-> Struct -> argumentCollection
well, i solved my own problem :O)
when copying from the query to the struct I wasn't referencing by the "row number" so things were very misleading when I dumped the resultant structure:
i needed:
<cfset y["#columnName#"] = x["#columnName#"][1] />
instead of
<cfset y["#columnName#"] = x["#columnName#"] />
so, thanks for reading and hopefully I save someone else some trouble.
Bill
On 6/15/05, Bill Rawlinson < [EMAIL PROTECTED]> wrote:
Hi,
Im doing something that seems like it should be fairly common yet it isn't working at all.
CFMX 6.1 Enterprise on Win XP Pro using IIS
I have a query pulling back data. Then, I'm moving the query data into a structure and finally I'm trying to initialize a CFC with this structure using the argumentCollection method.
However, when I do this I get an error telling me none of the data I am passing in is of the right type.
If I don't programmatically change the query into a structure it works fine. If you dump out the structure before you pass it you can see everything is fine. If you dump the arguments struct out everything is fine, if you test each argument with isSimpleValue or isNumeric they all pass with TRUE. Yet if you define the argument in the cfc with type of numeric or string it fails to initialize with the error message:
The argument ID passed to function init() is not of type numeric.
It doesn't matter what order the values are added to the structure either.
Has anyone else experienced this problem? If so is there a way around this without having to manually type each line of the structure creation? I intentionally alias all of my query columns to have the same name as the argument it matches up to so that I could do it this way. I am pulling back a query with close to 93 columns (and yes I need to) plus there are some other properties that get appended to the struct before I pass it in as an argumentCollection.
If you have any thoughts, ideas, suggestions, whatever, please help - thanks!
Here is a very, very simple example to illustrate what I am doing when things dont work (the very simple variable names make no difference what-so-ever).
### TESTVAR.CFM ####
<!--- very simple test of a wierd problem. --->
<cfscript>
x = queryNew("id,name,name1,name2,someid,otherid");
y = structNew();queryAddRow(x);
querySetCell(x,"id",1);
querySetCell(x,"name","name");
querySetCell(x,"name1","name1");
querySetCell(x,"name2","name2");
querySetCell(x,"someid",2);
querySetCell(x,"otherid",0);
</cfscript>
<cfloop list="#x.columnlist#" index="columnName">
<cfset y["#columnName#"] = x["#columnName#"] />
</cfloop><cfscript>
y.threeid = 3;
y.another = 'another';
</cfscript>
<cfscript>
t = createobject("component","var").init(argumentCollection=y);
t.dump(1);
</cfscript>
Here is the component, var
### VAR.CFC ####
<cfcomponent displayName="var" hint="" output="false">
<cffunction name="init" access="public" output="true" returntype=" test.var"><cfargument name="id" type="numeric" required="false" default="0" hint="" />
<cfargument name="another" type="string" required="false" default="" hint="" />
<cfargument name="name" type="string" required="false" default="" hint="" />
<cfargument name="name1" type="string" required="false" default="" hint="" />
<cfargument name="name2" type="string" required="false" default="" hint="" />
<cfargument name="someid" type="numeric" required="false" default="0" hint="" />
<cfargument name="otherid" type="numeric" required="false" default="0" hint="" />
<cfargument name="threeid" type="numeric" required="false" default="0" hint="" />
<cfscript>
variables.instance = structCopy(arguments);return this;
</cfscript>
</cffunction><!--- dump --->
<cffunction name="dump" access="public" output="true" return="void">
<cfargument name="abort" type="boolean" default="0" />
<cfdump var="#variables.instance#" />
<cfif arguments.abort>
<cfabort />
</cfif>
</cffunction>
</cfcomponent>
However, as I said, if I build the struct one line at a time it works fine:
### TESTVAR2.CFM ####
<!--- very simple test of a wierd problem. --->
<cfscript>
y = structNew();
</cfscript>
<cfscript>
y.threeid = 3;
y.another = 'another';
y.id = 2;
y.someid=3;
y.otherid=0;
</cfscript>
<cfscript>
t = createobject("component"," test.var").init(argumentCollection=y);
t.dump(1);
</cfscript>
--
[EMAIL PROTECTED]
http://blog.rawlinson.us
If you want Gmail - just ask.If you want Gmail - just ask. ----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone ( www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone ( www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
--
[EMAIL PROTECTED]
http://blog.rawlinson.us
If you want Gmail - just ask. ----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
