It
looks like you pass this to New
StudentNumber=foo
FistName=foo
LastName=foo
notice
your new method does,
<cfargument name="UserName" type="string"
required="false">
<cfargument name="Password" type="string" required="false">
<cfargument name="StudentNumber" type="string" required="false">
<cfargument name="StudentSequence" type="numeric" required="false" default="0">
<cfargument name="Password" type="string" required="false">
<cfargument name="StudentNumber" type="string" required="false">
<cfargument name="StudentSequence" type="numeric" required="false" default="0">
that
means arguments will be a join of what you sent and what you defined - so you
should have this in arguments:
Username
Password
StudentNumber
StudentSequence
FirstName
LastName
The
last two weren't defined, but your passed in in anyway.
That's
certainly what I would expect you to see - but you saw:
FirstName Howard
LastName Fore
PASSWORD [undefined struct element]
STUDENTNUMBER AC0230903
STUDENTSEQUENCE 0
USERNAME [undefined struct element]
FIRSTNAME Howard
LASTNAME Fore
PASSWORD [empty string]
STUDENTNUMBER AC0230903
STUDENTSEQUENCE 58314
USERNAME [empty string]
LastName Fore
PASSWORD [undefined struct element]
STUDENTNUMBER AC0230903
STUDENTSEQUENCE 0
USERNAME [undefined struct element]
FIRSTNAME Howard
LASTNAME Fore
PASSWORD [empty string]
STUDENTNUMBER AC0230903
STUDENTSEQUENCE 58314
USERNAME [empty string]
Very odd. You have discovered a 'magical' structure that has keys w/ the same name in them it seems. I'd say it was case - but notice you have two PASSWORDs, and student numbers.
=======================================================================
Raymond Camden, ColdFusion Jedi
Master for Mindseye, Inc
Member of Team
Macromedia
Email :
[EMAIL PROTECTED]
Blog :
www.camdenfamily.com/morpheus/blog
Yahoo IM : morpheus
"My ally is the
Force, and a powerful ally it is." - Yoda
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Howard Fore
Sent: Tuesday, April 01, 2003 2:20 PM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] Detecting arguments passed by CFINVOKEARGUMENT?
On Tuesday, April 1, 2003, at 02:51 PM, Raymond Camden wrote:
I'm confused - are you saying that when you call method foo, the values
of cfpoprerty get added to the arguments of foo? I've never seen that
before. Can you show us your method?
That's exactly the behavior I'm seeing. Code follows:
_newUserLookup.cfc (controller script to handle form input):
<cfsilent>
<!--- find user --->
<cfinvoke
component = "#application.stConfig.CFCOMPONENTS_PREFIX#com.ashworthcollege.student"
method = "new"
returnVariable = "student">
<cfinvokeargument
name="StudentNumber"
value="#ATTRIBUTES.StudentNumber#">
<cfinvokeargument
name="FirstName"
value="#ATTRIBUTES.FirstName#">
<cfinvokeargument
name="LastName"
value="#ATTRIBUTES.LastName#">
</cfinvoke>
<cfif student.studentNumber NEQ 0>
<!--- student found, put student object in session, go to the Profile Edit screen --->
<cfset session.student = student>
<cflocation url="" addToken="no">
<cfelse>
<!--- no student found --->
<cflocation url="" addToken="no">
</cfif>
</cfsilent>
/fontfamily>
Student.cfc:
<cfcomponent displayname="Student">
<cfproperty name="FirstName" type="string">
<cfproperty name="LastName" type="string">
<cfproperty name="StudentNumber" type="string">
<cfproperty name="StudentSequence" type="numeric" default="0">
<cfproperty name="UserName" type="string">
<cfproperty name="Password" type="string">
<cffunction name="new" output="false">
<cfargument name="UserName" type="string" required="false">
<cfargument name="Password" type="string" required="false">
<cfargument name="StudentNumber" type="string" required="false">
<cfargument name="StudentSequence" type="numeric" required="false" default="0">
<cfset studentData = StructNew()>
<cfquery name="qFindStudent" maxrows="1" datasource="#application.stConfig.DSN#">
select
s.FirstName as FirstName,
s.LastName as LastName,
s.StudentSequence as StudentSequence,
s.StudentNumber as StudentNumber,
s.UserName as UserName,
s.Password as Password
from
Students s
where
<!--- lookup base on FirstName/LastName/StudentNumber --->
<cfif
StructKeyExists(arguments,"FirstName") and
StructKeyExists(arguments,"LastName") and
StructKeyExists(arguments,"StudentNumber")>
s.FirstName = <cfqueryparam value="#arguments.FirstName#" cfsqltype="CF_SQL_VARCHAR">
and
s.LastName = <cfqueryparam value="#arguments.LastName#" cfsqltype="CF_SQL_VARCHAR">
and
s.StudentNumber = <cfqueryparam value="#arguments.StudentNumber#" cfsqltype="CF_SQL_VARCHAR">
</cfif>
<!--- lookup based on StudentSequence --->
<cfif
StructCount(arguments) EQ 1 and
StructKeyExists(arguments,"StudentSequence")>
s.StudentSequence = <cfqueryparam value="#arguments.StudentSequence#" cfsqltype="CF_SQL_INTEGER">
</cfif>
<!--- lookup base on Username and Password --->
<cfif
StructCount(arguments) EQ 2 and
StructKeyExists(arguments,"UserName") and
StructKeyExists(arguments,"Password")>
s.UserName = <cfqueryparam value="#arguments.UserName#" cfsqltype="CF_SQL_VARCHAR">
and
s.Password = <cfqueryparam value="#arguments.Password#" cfsqltype="CF_SQL_VARCHAR">
</cfif>
</cfquery>
<cfif qFindStudent.recordcount eq 1>
<cfset studentData.FirstName = trim(qFindStudent.FirstName)>
<cfset studentData.LastName = trim(qFindStudent.LastName)>
<cfset studentData.StudentSequence = trim(qFindStudent.StudentSequence)>
<cfset studentData.StudentNumber = trim(qFindStudent.StudentNumber)>
<cfset studentData.UserName = trim(qFindStudent.UserName)>
<cfset studentData.Password = trim(qFindStudent.Password)>
<cfset studentData.CFCArguments = arguments >
</cfif>
<cfreturn studentData>
</cffunction>
/fontfamily>
And finally, in newUserProfileEdit.cfm I have a <cfdump var="#session.student#"> which produces this (view in monospaced font to make sense):
struct
CFCARGUMENTS struct
FirstName Howard
LastName Fore
PASSWORD [undefined struct element]
STUDENTNUMBER AC0230903
STUDENTSEQUENCE 0
USERNAME [undefined struct element]
FIRSTNAME Howard
LASTNAME Fore
PASSWORD [empty string]
STUDENTNUMBER AC0230903
STUDENTSEQUENCE 58314
USERNAME [empty string]
/fontfamily>
--
Howard Fore, [EMAIL PROTECTED]
"Crackers: Because your cheese needs a buddy."
