0
New Here
,
/t5/coldfusion-discussions/using-cfcomponent-with-parameters/td-p/433698
Dec 31, 2007
Dec 31, 2007
Copy link to clipboard
Copied
Does anyone know what wrong with my codes?
-- Codes --
<cfset strUsername = "Raymond">
<cfinvoke component="cfc.content" method="funcWelcomeMsg"><cfinvokeargument name="strUsername" value="Raymond"></cfinvoke>
-- Component --
<cfcomponent displayname="content" hint="Component to store content manipulation functions">
<!--- Function to return Welcome messages --->
<cffunction name="funcWelcomeMsg">
<cfparam name="strUsername" type="string">
<cfoutput>
<table width="200" border="0" cellpadding="0" cellspacing="0" class="nav_bar">
<tr>
<td align="right">Welcome, #strUsername#</td>
</tr>
</table>
</cfoutput>
</cffunction>
</cfcomponent>
-- Error --
The required parameter strUsername was not provided.
This page uses the CFPARAM tag to declare the parameter strUsername as required for this template. The parameter is not available.Please verify that you have passed or initialized the parameter correctly. If you wish to set a default value for the parameter you should use the DEFAULT attribute of the CFPARAM tag.
-- Codes --
<cfset strUsername = "Raymond">
<cfinvoke component="cfc.content" method="funcWelcomeMsg"><cfinvokeargument name="strUsername" value="Raymond"></cfinvoke>
-- Component --
<cfcomponent displayname="content" hint="Component to store content manipulation functions">
<!--- Function to return Welcome messages --->
<cffunction name="funcWelcomeMsg">
<cfparam name="strUsername" type="string">
<cfoutput>
<table width="200" border="0" cellpadding="0" cellspacing="0" class="nav_bar">
<tr>
<td align="right">Welcome, #strUsername#</td>
</tr>
</table>
</cfoutput>
</cffunction>
</cfcomponent>
-- Error --
The required parameter strUsername was not provided.
This page uses the CFPARAM tag to declare the parameter strUsername as required for this template. The parameter is not available.Please verify that you have passed or initialized the parameter correctly. If you wish to set a default value for the parameter you should use the DEFAULT attribute of the CFPARAM tag.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Engaged
,
Dec 31, 2007
Dec 31, 2007
Don't use cfparam in your cffunction. Use cfargument.
Engaged
,
/t5/coldfusion-discussions/using-cfcomponent-with-parameters/m-p/433699#M39152
Dec 31, 2007
Dec 31, 2007
Copy link to clipboard
Copied
Don't use cfparam in your cffunction. Use cfargument.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
alternative
AUTHOR
New Here
,
LATEST
/t5/coldfusion-discussions/using-cfcomponent-with-parameters/m-p/433700#M39153
Dec 31, 2007
Dec 31, 2007
Copy link to clipboard
Copied
thx for ur advice, long time din codes CFML already 🙂
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

