Answered
Using CFComponent with parameters
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.
