Outputting a CFC Component

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Outputting a CFC Component

    Can someone please help me with this simple request. I get an error message
    when I try and output the results of a simple CFC Component. Here is the error
    message:

    Attribute validation error for tag cfoutput.
    The value of the attribute query, which is currently "GetHomePageInfoRet", is
    invalid.

    Here is the component and the cfinvoke.




    <cfcomponent displayname="Home Page Content" hint="This manages content">
    <cffunction name="GetHomePageInfo" output="yes" returntype="query"
    displayname="Get Home Page Content" hint="Function to get the content for the
    PS Hospitality Home Page">
    <cfquery name="gethome_info"
    datasource="psfu"
    dbtype="ODBC">SELECT *
    FROM home
    </cfquery>
    <cfreturn gethome_info>
    </cffunction>
    </cfcomponent>

    <p class="homeheader"><cfinvoke
    component="psaims.PScontent"
    method="GetHomePageInfo"
    returnvariable="GetHomePageInfoRet"><cfoutput
    query="GetHomePageInfoRet">#subtag#</cfoutput></p>

    <p align="left"><cfoutput
    query="GetHomePageInfoRet">#info#</cfoutput></cfinvoke></p>

    murpg Guest

  2. Similar Questions and Discussions

    1. Problems outputting to PDF and PS
      I apologize if this isn't the correct newsgroup for this inquiry but here goes. I am trying to output textfile (from Appleworks) to either a PDF...
    2. Outputting an animation 101
      I created a home page via ImageReady 7.0 and there is an image on the page that is an animation. It is basically a photo that is fading from 100% to...
    3. [PHP] XX outputting X signs
      Would it not make sese to store the number as a decimal and have the '£' added at output? George, in Oxford, where £££=pints
    4. £ outputting £ signs
      Hello all Can someone tell me where i am going wrong here. I am trying to echo a '£' to the screen which has come from a database field. I get the...
    5. outputting XML from PHP
      Today I decided to teach myself both PHP and XML ... so I decided to make a little address book. After I finished it I found this:...
  3. #2

    Default Re: Outputting a CFC Component

    Try this:

    <cfcomponent displayname="Home Page Content" hint="This manages content">
    <cffunction name="GetHomePageInfo" output="yes" returntype="query">
    <cfset var gethome_info = "" />
    <cfquery name="gethome_info" datasource="psfu" dbtype="ODBC">
    SELECT * FROM home
    </cfquery>
    <cfreturn gethome_info>
    </cffunction>
    </cfcomponent>

    Darryl


    "murpg" <webforumsuser@macromedia.com> wrote in message news:d85j56$es2$1@forums.macromedia.com...
    > Can someone please help me with this simple request. I get an error message
    > when I try and output the results of a simple CFC Component. Here is the error
    > message:
    >
    > Attribute validation error for tag cfoutput.
    > The value of the attribute query, which is currently "GetHomePageInfoRet", is
    > invalid.
    >
    > Here is the component and the cfinvoke.
    >
    >
    >
    >
    > <cfcomponent displayname="Home Page Content" hint="This manages content">
    > <cffunction name="GetHomePageInfo" output="yes" returntype="query"
    > displayname="Get Home Page Content" hint="Function to get the content for the
    > PS Hospitality Home Page">
    > <cfquery name="gethome_info"
    > datasource="psfu"
    > dbtype="ODBC">SELECT *
    > FROM home
    > </cfquery>
    > <cfreturn gethome_info>
    > </cffunction>
    > </cfcomponent>
    >
    > <p class="homeheader"><cfinvoke
    > component="psaims.PScontent"
    > method="GetHomePageInfo"
    > returnvariable="GetHomePageInfoRet"><cfoutput
    > query="GetHomePageInfoRet">#subtag#</cfoutput></p>
    >
    > <p align="left"><cfoutput
    > query="GetHomePageInfoRet">#info#</cfoutput></cfinvoke></p>
    >

    Darryl A. J. Staflund Guest

  4. #3

    Default Re: Outputting a CFC Component

    I tried your suggestion. Is there something wrong with the way I am trying to
    output this? Here is my error message.

    The value of the attribute query, which is currently "GetHomePageInfoRet", is
    invalid.

    murpg Guest

  5. #4

    Default Re: Outputting a CFC Component

    You don't need to hae output set to yes on this function. This should ONLY be
    used if the function itself will be displaying data, and this is not
    recommended. You are not outputting anything, you are returning a query.

    I don't know if that is causing the problem, but I can't see anything else
    wrong with this call.

    TA-Selene Guest

  6. #5

    Default Re: Outputting a CFC Component

    > I don't know if that is causing the problem, but I can't see anything else
    > wrong with this call.
    Really?

    What about the fact the <cfoutput> statements are *within* the <cfinvoke>
    tags?

    Probably best to have them AFTER the method has been called, not during,
    eh? ;-)

    NO:
    <cfinvoke
    component="psaims.PScontent"
    method="GetHomePageInfo"
    returnvariable="GetHomePageInfoRet"><cfoutput
    query="GetHomePageInfoRet">#subtag#</cfoutput></p>

    <p align="left"><cfoutput
    query="GetHomePageInfoRet">#info#</cfoutput></cfinvoke>

    YES:
    <cfinvoke
    component="psaims.PScontent"
    method="GetHomePageInfo"
    returnvariable="GetHomePageInfoRet">

    <cfoutput
    query="GetHomePageInfoRet">#subtag#</cfoutput></p>

    <p align="left"><cfoutput
    query="GetHomePageInfoRet">#info#</cfoutput>


    Note: You only need a closing </cfinvoke> tag if you're using
    <cfinvokeargument> tags.

    --

    Adam
    Adam Cameron Guest

  7. #6

    Default Re: Outputting a CFC Component

    I missed that you had the </cfinvoke> tag after your CFOUTPUT. That is indeed
    what is causing the problem. The queries won't exist until after the invoke is
    processed, which won't be finished until the closing tag is reached. The only
    thing you should have nested within your CFINVOKE tags are tags that pass
    information to/from the object.

    TA-Selene Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139