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.
Archived Comments
It is odd. If you try every number (0-9), some error ... some pull results, and others just do nothing. For instance, 1 and 3 error but 2 does nothing. 5 on the other hand finds the result "500 error".
Putting an underscore _ wont error, but it also wont show the result found, which is:
["test","camden","getter","robot chicken","william ukoh","william","coldfusion rocks","a","andrea","chad"]
I am just testing your flex solution to the blog engine. Might consider one myself, this looks interesting for sure
This is a strange bug. Its now been logged as a bug in our bugtracker.
Thanks for pointing it out.
It does the exact same thing for binding values to a drop down to auto-populate. In my case, it converted my "Yes" to "true".
Hi Ray,
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.
I don't know. Give it a try in 8.0.1 though - that fixed a lot of bugs.
I'm running 8.0.1 and I'm having the same issue. I'm sifting through a list of invoice IDs, restaurant food items and names and every time the item is a pure integer something insists that it be returned without quotes, making the autosuggest fail some of the time with the 1D array error. No matter how I try to cast the results, I can't get around it. Odd an annoying.
Yeah, I don't think it's fixed. We're also running 8.0.1 and I still get the same error.
Having the same issue here as well. Simple form for retrieving ticket #'s (formatted 'mmddyyxxx' with 'xxxx' being an incremental). Any digit entered into the input field throws the "1D Array" error. Running 8.0.1.
I'm really surprised this isn't fixed in 8.0.1. Or the CHF for it. I guess I'd recommend then not using this feature at all. You could probably find a simple jQuery solution, and Spry supports autosuggest as well.
I was having binding problems with autosuggest as well when pulling back long numbers with leading zeros (e.g. 0001234567) and got scientific notation added by JSON serialization. I figured out a workaround that solves the binding and serialization problem for the time being.
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.
Hi there,
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...
It's the first one, and works very nice.
Good look fellows.
See you around.
Bye
Has anyone come up with a solution for 'Bind failed for autosuggest, bind value is not a 1D array of strings'. Changing the returned results from my CFC to a string has not made a difference. It seems to only happen in Firefox.
See my suggestion above: <cfreturn "$," & ValueList(someQuery.SOME_COLUMN)> That worked for me.
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.
Thanks for the suggestion Greg, but that doesn't change the behavior for me. Still the same result. Any other ideas? Like I said, it only seems to happen in Firefox, and it's also related to the speed you type. If I type slow enough for the autocomplete to keep up, everything is cool. But if I type really fast and hit enter the error pops up.
I used the autosuggestBindDelay="1" parameter (1 second) in my <cfinput> tag and had fewer problems with speed of typing than if I left the parameter out (default is 0.5 seconds). Set higher if needed but anything higher than 3 would not seem useful for an autosuggest feature. The speed of your network and .cfc calls could affect performance. If the round-trip Ajax call takes 2 seconds and your autosuggestBindDelay is at the default of 0.5 seconds, I can imagine some collisions occurring as multiple Ajax requests return in 2, 4, 6, etc. seconds.
I have the luxury of targeting only MSIE.
I know this was posted months ago, but I thought I'd add a quick note about integers and SerializeJSON:
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.
Bind Failed Error -
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
While Adobe works on a fix, I came up with a work-around.
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...
After coming across this thread (and groaning appropriately), I found that if I merely prepend a comma to the string result, it prevents the conversion of a single numerical string result from being interpreted as a number. In other words (and in pseudocode),
if (recordCount EQ 1)
return ',' + ValueList(...);
else
return ValueList(...);
So even worse, serializeJSON converts numeric strings to scientific notation!
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.
Unfortunately no, not in CF9 either.
This is ridiculous. I'm using EXTJS with CF being the backside (intended). And I'm returning pretty large structures of data via ajax to my ext code. And all my INT's are converted to scientific notation. Useless. Coldfusion screws me again. Another example of shoddy bug tracking and implementation by the Coldfusion team. I am committed to Coldfusion, but only because I'm forced. After dealing with the countless bugs in cfdocument, cfchart, the entire cf8 ajax libraries... now a simple function like serializejson can't return an int??? Stupid stupid stupid.
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.
Dave, how about trying JSON.cfc?
http://www.epiphantastic.co...
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.
I never blogged on it - just tweeted. But, yeah, just do a javacast(int, yourval) and then serializeJSON and you'll avoid the annoying 'decimal' conversion.
I'm of the opinion that CF keeps adding features that sound really cool on paper but when you go to use them they don't work quite right and never get fixed. Adobe just moves on to creating the next cool sounding widget to get you to buy the next version, only to find it doesn't work the way it's supposed to either. Autocomplete, cfmail's slow performance, and Flash based forms jump to mind as examples that have caused me headaches because they sort of work, but not quite.
Well, we are a bit off topic now, but let me respond to this a bit.
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.
Thanks fellas.
<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!
I'm having the same problem with yes/no string being converted to boolean values when serialized.
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?
To be fair, 400+ objects with 50 keys is a lot to serialize.
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.
To fix this, comment out line 28 in cfautosuggest.js
//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.
string did not work and i wanted more bits than log so I did bigdecimal.
bigdecimal (converts to java.math.BigDecimal)
output.id = javacast('bigdecimal', URL.id);
Very, very frustrating that this is still a bug nearly four years later.
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?
JSON seriliazation has been much improved in CF9. As for the autusuggest tool, if it still doesnt work well for you, consider the jQuery UI one. You can use that easily enough with CF.
JavaCast("Long", Variable) fixs the issue before serializing the data structure.