Posted in ColdFusion | Posted on 03-17-2008 | 5,868 views
Thanks to Ed Tabara for pointing this out. If you type "1" in the search field at ColdFusion Bloggers, you will get a JavaScript error:
The page at http://www.coldfusionbloggers.org says:Bind failed for autosuggest search_query, bind value is not a 1D array of strings [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]
If you introspect the result from my server, you see something like this:
[10.0,123.0,"1ssblog","1smartsolution"]
Notice that the first two results were numbers, not strings. I tried to 'fool' JSON a bit. I added "" to the number to see if that would do it and it didn't work. Interestingly enough, if you add " " to your data, serializeJSON will keep the padding on the strings, but removes it from the numbers. So even though my data was "10(space)", serializeJSON ignored it.
So it looks like 2 possible bugs. The client side code should allow for any simple value in the array - numbers, strings, or dates. And it looks like maybe serializeJSON is a bit overzealous in converting values. I can understand converting 10 to 10.0, but "10(space)" should be left alone, especially if "Ray(space)" is left alone.


["test","camden","getter","robot chicken","william ukoh","william","coldfusion rocks","a","andrea","chad"]
Thanks for pointing it out.
Do you know if this problem was ever resolved? I have just implemented autosuggest and am getting the "bind failed for autosuggest" error when I type a number into the autosuggest box.
Thanks.
In your CFC method, return an extra alphabetical list element that will never match any data in the first character of data--I decided to use "$" but you could use any character. For example: <cfreturn "$," & ValueList(someQuery.SOME_COLUMN)> The "$" never matches any of my data but it causes the bind to work and problems with JSON serialization of the long number are also solved.
I spend a lot time try to fix this issue, but now I known I not the only, like Raymond said, just wait for a fix.
To continue with my project I use this Ben solution.
"Using the client-side auto-suggest control"
http://www.adobe.com/devnet/coldfusion/articles/cf...
It's the first one, and works very nice.
Good look fellows.
See you around.
Bye
Also, make sure that if you are using CFCs, do not have any end of request processing (OnRequestEnd.cfm or method in application.cfc) that might add additional characters or blank spaces to the returned data. Once I fixed that, my autosuggest fields started working.
I have the luxury of targeting only MSIE.
For integer values and SerializeJSON note that this will return an integer in JSON form:
<cfset someInt = 1 />
<cfset JavaCast("int", someInt) />
<cfset SerializeJSON(someInt) />
Otherwise values you think are integers may be treated as strings or floating points.
The cause of the error for me was the JSON text being returned in not absolutely JSON (it included header in the onRequestStart). Removing that worked! Not a Bug
Disable the Enter key as a means to submit the form. In other words, force the user to click an actual Submit button.
Install the js here: http://www.dynamicdrive.com/dynamicindex16/disable...
if (recordCount EQ 1)
return ',' + ValueList(...);
else
return ValueList(...);
Try:
test = {x="121414124"};
return serializeJSON(test);
you'll get {"X":1.21414124E8}
I even tried javaCast'ing it is a string, yet this still converts it to scientific notation. This is a horrible bug in CF 8.x. Anyone have a workaround BESIDES adding crap to the string and then doing a replace()? That's so ugly.
I'm returning too much data to selectively add "$" or "," to the beginning of my integers. Additionally, I refuse that solution on grounds of principle.
Does anyone know anything more about this?
Sorry for the rant. I don't only hate coldfusion... occasionally I love hating it.
http://www.epiphantastic.com/cfjson/
I believe it may handle the numeric issue a bit better.
Also, you can consider using SQL to prepend your column with $ (you will need to cast as well). It would be done totally in SQL then and should perform well. You can also use JavaCast to cast the data to int - Todd Sharp has blogged on that.
1) Slow Mail
Are you sure? Last time I checked cfmail was EXTREMELY fast. I don't have the #s in front of me and I may be wrong, but I thought CF8 Ent was clocked at 500K emails per hour. Remember, once cf hands off the message, it is up to the mail server to deliver it.
2) Flash Forms/other features
Well, I definitely don't use Flash Forms anymore. They were added before the Flex SDF was free so now I definitely push folks to Flex. That being said, it is important to remember that now every feature is for you! Ajax is a great example of this. CF provides support for Ajax both in pluming (JSON serialization, returnFormat in CFCs) and in UI. The UI stuff isn't perfect. You can do more with Ext/jQuery UI. But for people who know little to no Ajax, it is a killer feature.
<cfset myVar = javacast('int' origIntVal)>
<cfreturn serializeJson(myVar)>
Did the trick. I had read up above in this thread that javacast did NOT work... but that guy was javacast'ing to a string and not an int.
I take back what I said about Coldfusion. Actually, I don't take it back. Coldfusion is the pits, but its user base is excellent. I'm always on your blogs and getting great help. Thanks for all the help.
I'll give cfjson a shot too. That will probably be a better long term solution. My data structures are pretty big and I don't feel much like having to javacast everything. Though I will if I have to. I'm just glad that I have a solution.
Thanks again!
Adobe needs to fix this. The JSON.cfc library is considerably slower for very large (an array of 400 + objects (with more nested structs) each with 50 keys).
But it would be even slower to iterate through this big ass piece of data and scrub it to get my data back in the correct format.
If it was a small amount of data it would be okay to add a space after "yes " and then remove it on the way back (post deserialize()), but as it stands, I am running out of options. Does any one have any suggestions?
That being said - if you don't need _dynamic_ serialization (ie, you know exactly what you want - you can write your own code. JSON is pretty trivial to generate. Just be sure to use stringBuffer's via createObject.
//ColdFusion.handleError(_35.onbinderror,"autosuggest.loadautosuggest.invalidvalue","widget",[_34.autosuggestid]);
And comment out line 75 in cfmessage.js //m['autosuggest.loadautosuggest.invalidvalue']='Bind failed for autosuggest {0}, bind value is not a 1D array of strings'
Make sure to add a comment that you changed the code for documentation, and re-check if you upgrade from cf8 to 9.
bigdecimal (converts to java.math.BigDecimal)
output.id = javacast('bigdecimal', URL.id);
None of the suggestions in this thread have worked for me.
It's quite frustrating when you go to do something in CF and it just does not work. And they know it.
I need a MaiTai, who's with me?
[Add Comment] [Subscribe to Comments]