Problem with cfinput autosuggest and cfcomponent
I am new to using cfcomponent and autosuggest. I followed the sample given in the Adobe Help Adobe ColdFusion 9 * Using Ajax User Interface Components and Features
However, I am not getting the autosuggest to work at all. This is what I did:
1. I created a Suggestcfc.cfc under a subdirectory called "components"
The Suggestcfc.cfc is as follows:
<cfcomponent output="false">
<cffunction name="getProduct" access="remote" returntype="array" output="false">
<cfargument name="suggestvalue" required="true">
<cfset var myarray = ArrayNew(1)>
<cfquery datasource="mydatabase" name="getlist">
SELECT DISTINCT productname FROM products
WHERE productname LIKE <cfqueryparam value="#suggestvalue#%" cfsqltype="cf_sql_varchar">
</cfquery>
<cfloop query="getlist">
<cfset arrayAppend(myarray, productname)>
</cfloop>
<cfreturn myarray>
</cffunction>
<cffunction name="init" output="false">
<cfreturn this>
</cffunction>
</cfcomponent>
2. I have a test.cfm as:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<cfset suggest = createObject("component", "components.Suggestcfc").init()>
<cfform>
<cfinput type="text" autosuggest="suggest.getProducts({cfautosuggestvalue})" name="string">
</cfform>
</body>
</html>
So when I run the test.cfm it only showed a box and when I started typing, nothing is being suggested (retrieve from the products table). What am I doing wrong here? Any help is appreciated. Thanks in advance.
