tags:

views:

60

answers:

2

I'm trying to understand ColdFusion, as I am coming from ASP.NET. I've put together a sample page to piggy-back off some already finished code -- but I can't seem to get the actual data from the object I am creating:

<cfset objProduct = createObject("component", "com.MyObj.Product")>
<cfset prodExists = objProduct.getProduct(10)>
<html>
<head/>
<body>
<h2>#objProduct.ProductName#</h2>
</body>

... It simply prints the literal #objProduct.ProductName# text, and not the data from within the object. Any idea where I'm going astray?

Thanks!

+6  A: 

Don't forget the <cfoutput>!

<cfoutput>
<html>
  <head>
    <title>Test</title>
  </head>
  <body>
    <h2>#HtmlEditFormat(objProduct.ProductName)#</h2>
  </body>
</html>
</cfoutput>
Justice
Also, dont forget `HTMLEditFormat()`. It's the one and only reason that XSS attacks even exist - people constantly forget to HTML-escape their output. So... this should be `#HTMLEditFormat(objProduct.ProductName)#`, actually.
Tomalak
@Tomalak Thanks for the tip.
Justice
+1  A: 
  1. You forgot the CFOUTPUT tags.
  2. You're trying to output the wrong variable.

    #objProduct.getProduct(10)#

or

<cfoutput>#prodExists#</cfoutput>
iKnowKungFoo