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="#application.stVirtualPath.approot#/newUserProfileEdit.cfm" addToken="no">
<cfelse>
<!--- no student found --->
<cflocation url="#application.stVirtualPath.approot#/newUserLookup.cfm?FirstName=#ATTRIBUTES.FirstName#&LastName=#ATTRIBUTES.LastName#&StudentNumber=#ATTRIBUTES.StudentNumber#" addToken="no">
</cfif>
</cfsilent>

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>

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]




--
Howard Fore, [EMAIL PROTECTED]
"Crackers: Because your cheese needs a buddy."

Reply via email to