Skip to main content
Participant
December 31, 2007
Answered

Using CFComponent with parameters

  • December 31, 2007
  • 2 replies
  • 729 views
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.
    This topic has been closed for replies.
    Correct answer cfjedimaster
    Don't use cfparam in your cffunction. Use cfargument.

    2 replies

    Participant
    December 31, 2007
    thx for ur advice, long time din codes CFML already :)
    cfjedimaster
    cfjedimasterCorrect answer
    Inspiring
    December 31, 2007
    Don't use cfparam in your cffunction. Use cfargument.