Reputation: 145
This is how I am passing a string parameter to a component in ColdFusion 10:
<cfset DeptObj = New CompEmp('#Trim(DeptId)#','#Trim(DeptSecId)#')>
<cfset EmpStatus = DeptObj.GetEmp('NewHire')> ----> passing a string
My question is, how do I pass a ColdFusion structure to a function in a component instead of a string?
For example, if I have the following structure:
<cfset str_MyBioInfo = {myFName="#GetBio.FName#", myLName="#GetBio.LName#",
myBday="#GetBio.BDate#"}
And I want to pass str_MyBioInfo
to a component, do I do it this way?
<cfset BioObj = New BioInfo()>
<cfset BioInfoDetail = BioObj.GetBio(str_MyBioInfo)> ----> ?
And in the <cffunction>
I have MybioInfo
structure as an argument like this:
<cffunction name="GetBio">
<cfargument name="str_MyBioInfo" type="Struct"> ---> ?
</cffunction>
Upvotes: 0
Views: 358
Reputation: 635
I think you are looking for how to pass a collection of arguments to a function:
<cfset str_MyBioInfo = { FName="firstName"
, LName="LastName"
, BDate="YourdateOfBirth"
} />
<cfset BioObj = createObject("component", "BioObj")>
<cfset BioInfoDetail = BioObj.GetBio(argumentCollection = str_MyBioInfo)>
<cffunction name="GetBio">
<cfargument name="FName" type="String" required="true" >
<cfargument name="LName" type="String" required="true" >
<cfargument name="BDate" type="String" required="true" >
</cffunction>
Upvotes: 1