Skip to main content
Known Participant
June 13, 2009
Answered

passing attributes

  • June 13, 2009
  • 1 reply
  • 506 views

Hi,

I can pass attributes to a CFC like this but how do I use them? I tried <cfoutput>#firstname</cfoutput> but firstname is undefined.

<cfinvoke component="toastcfc/header" method="header"  firstname="john" lastName="kidd">

    This topic has been closed for replies.
    Correct answer Kibbage-Data-Services

    A few typo's that may or may not be in your actual code:

    <cfoutput>#firstname</cfoutput>

    Should be

    <cfoutput>#firstname#</cfoutput>

    or better yet

    <cfoutput>#arguments.firstname#</cfoutput>

    and

    <cfinvoke component="toastcfc/header" method="header"  firstname="john" lastName="kidd">

    Should be

    <cfinvoke component="toastcfc.header" method="header"  firstname="john" lastName="kidd" />

    Let's assume that your actual code is correct. In that case you must have a directory called toastcfc (or a mapping) and in it a file called header.cfc and in it a function called header. What does the actual code in the <cffunction ... > look like? Do you have a <cfargument name="header" type="string"> tag?

    1 reply

    Kibbage-Data-ServicesCorrect answer
    Inspiring
    June 13, 2009

    A few typo's that may or may not be in your actual code:

    <cfoutput>#firstname</cfoutput>

    Should be

    <cfoutput>#firstname#</cfoutput>

    or better yet

    <cfoutput>#arguments.firstname#</cfoutput>

    and

    <cfinvoke component="toastcfc/header" method="header"  firstname="john" lastName="kidd">

    Should be

    <cfinvoke component="toastcfc.header" method="header"  firstname="john" lastName="kidd" />

    Let's assume that your actual code is correct. In that case you must have a directory called toastcfc (or a mapping) and in it a file called header.cfc and in it a function called header. What does the actual code in the <cffunction ... > look like? Do you have a <cfargument name="header" type="string"> tag?

    HulfyAuthor
    Known Participant
    June 14, 2009

    <cfoutput>#arguments.firstname#</cfoutput> works.

    thanks.