Re: Finding if a key exists in a struct based on a variable name
On a side note, if you're after an output of 'yes' or 'no', this may be cleaner: #YesNoFormat( StructKeyExists(x.classAssign, #y#head) )# Dominic On 8 September 2010 02:30, Michael Grant mgr...@modus.bz wrote: So I went back and read the docs for IIF. I haven't looked at them in years and I'm shocked that I've used it for SO many years without really knowing exactly how it worked. I would've first read about IIF pre version 5. I can't even find the docs for it. Version 5's description is a little vague. You learn something new every day I guess. That's awesome. Thanks again Rex. On Tue, Sep 7, 2010 at 8:49 PM, Michael Grant mgr...@modus.bz wrote: Wow. I had no idea you could wrap DE in Evaluate. Did you come figure this out through trial and error or have I just never read it? Thanks for the post rex. On Tue, Sep 7, 2010 at 8:34 PM, rex li...@pgrworld.com wrote: A lot of people get DE() wrong. IIF does not short-circuit (http://en.wikipedia.org/wiki/Short-circuit_evaluation), meaning that your DE() gets evaluated even if the condition is FALSE. So, this will break: #iif(false, notFalse, false)# since notFalse does not exist. Same here: #iif(true, true, fols)# since fols does not exist. And finally your code: #iif(false, DE(x.classAssign[#y#head]), DE(''))# breaks since x.classAssign[NAMEhead] does not exist. DE evaluates a STRING parameter and finds double-quotes. If you pass in a variable, it looks for the value of that variable. Since you are passing x.classAssign[#y#head], it looks for x.classAssign[NAMEhead] and breaks. This will work: evaluate(DE(x.classAssign['#y#head'])) - notice the single-quotes surrounding #y#head! This is because we don't want DE to escape this, so we don't want to wrap it around double-quotes! Here is the code (I used no value instead of , but it's still the same code that you use): cfset x.classAssign = { NameHead = this head, NoNameHead = that head } / cfoutput cfset y = Name / #iif(StructKeyExists(x.classAssign,#y#head), evaluate(DE(x.classAssign['#y#head'])), DE(no value))#hr / cfset y = NoExist / #iif(StructKeyExists(x.classAssign,#y#head), evaluate(DE(x.classAssign['#y#head'])), DE(no value))#hr / cfset Y = 'Any' / See how these two differ: br / #DE(x.classAssign['#y#head'])#br / #DE('x.classAssign[#y#head]')# /cfoutput Michael Grant wrote: HA! So I'm not the only one! So I thought DE meant Delay Evaluation as in Don't evaluate what's in these little brackets this until you've satisfied the IIF condition. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336893 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Finding if a key exists in a struct based on a variable name
Thanks. I'm actually after the structvalue if it exists and a zero length string if it doesn't. It looks like Rex has me sorted though. Thanks Dom. On Wed, Sep 8, 2010 at 3:24 AM, Dominic Watson watson.domi...@googlemail.com wrote: On a side note, if you're after an output of 'yes' or 'no', this may be cleaner: #YesNoFormat( StructKeyExists(x.classAssign, #y#head) )# Dominic On 8 September 2010 02:30, Michael Grant mgr...@modus.bz wrote: So I went back and read the docs for IIF. I haven't looked at them in years and I'm shocked that I've used it for SO many years without really knowing exactly how it worked. I would've first read about IIF pre version 5. I can't even find the docs for it. Version 5's description is a little vague. You learn something new every day I guess. That's awesome. Thanks again Rex. On Tue, Sep 7, 2010 at 8:49 PM, Michael Grant mgr...@modus.bz wrote: Wow. I had no idea you could wrap DE in Evaluate. Did you come figure this out through trial and error or have I just never read it? Thanks for the post rex. On Tue, Sep 7, 2010 at 8:34 PM, rex li...@pgrworld.com wrote: A lot of people get DE() wrong. IIF does not short-circuit (http://en.wikipedia.org/wiki/Short-circuit_evaluation), meaning that your DE() gets evaluated even if the condition is FALSE. So, this will break: #iif(false, notFalse, false)# since notFalse does not exist. Same here: #iif(true, true, fols)# since fols does not exist. And finally your code: #iif(false, DE(x.classAssign[#y#head]), DE(''))# breaks since x.classAssign[NAMEhead] does not exist. DE evaluates a STRING parameter and finds double-quotes. If you pass in a variable, it looks for the value of that variable. Since you are passing x.classAssign[#y#head], it looks for x.classAssign[NAMEhead] and breaks. This will work: evaluate(DE(x.classAssign['#y#head'])) - notice the single-quotes surrounding #y#head! This is because we don't want DE to escape this, so we don't want to wrap it around double-quotes! Here is the code (I used no value instead of , but it's still the same code that you use): cfset x.classAssign = { NameHead = this head, NoNameHead = that head } / cfoutput cfset y = Name / #iif(StructKeyExists(x.classAssign,#y#head), evaluate(DE(x.classAssign['#y#head'])), DE(no value))#hr / cfset y = NoExist / #iif(StructKeyExists(x.classAssign,#y#head), evaluate(DE(x.classAssign['#y#head'])), DE(no value))#hr / cfset Y = 'Any' / See how these two differ: br / #DE(x.classAssign['#y#head'])#br / #DE('x.classAssign[#y#head]')# /cfoutput Michael Grant wrote: HA! So I'm not the only one! So I thought DE meant Delay Evaluation as in Don't evaluate what's in these little brackets this until you've satisfied the IIF condition. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336894 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
cfdocument and flashpaper (link to flash if not installed)
Hi, I am using cfdocument with format flashpaper. however, if users do not have flash installed instead of informing them of this and providing them with a link to download flash, the system is showing the download window. is there anyway to inform the user of this problem and provide them with a link to the flash download page? thanks ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336895 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Need some fresh eyes on an application
Might have been a temporary network problem. Everything seems to be accessible now. Thanks, Paul Login doesn't work (at the moment?). So I cannot help with testing. I'm using Opera, IE8, Firefox, Safari and Chrome on Windows 7, but none of them want to login with the credentials provided. Sebastiaan = So long and thanx 4 all the fish == Onlinebase.nl Date: Mon, 6 Sep 2010 07:01:58 -0400 Subject: RE: Need some fresh eyes on an application From: r...@whitestonemedia.com To: cf-talk@houseoffusion.com Not being familiar with mssql (I'm a mysql user), I made some entry mistakes when trying to create a table. An error message would pop up identifying my mistake, but then when I clicked ok to go back and correct the error, the form for entering a column had disappeared. Is that supposed to happen? I would think that the alert would disappear, then the form would reappear. Rick -Original Message- From: Paul Day [mailto:p...@nucomsolutions.com] Sent: Friday, September 03, 2010 7:34 AM To: cf-talk Subject: Re: Need some fresh eyes on an application (Sorry, forgot the demo URL...) I have created a test account with the following credentials: Demo URL: http://www.nucomsolutions.com/dbDiscover Server name: sql1100.shared-servers.com Port number: 1086 Username: hof_test Password: hof_test I'm not allowed to do anything with the user accounts or adding databases, since this is on a shared database hosting server. All interested are encouraged to play around and offer any feedback. Remember this is a work in progress, so a lot of functionality is yet to be added. Thanks, Paul Paul Day Owner/Principal Architect phone: 410.241.8465 email: p...@nucomsolutions.com web: http://www.nucomsolutions.com/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336896 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Need some fresh eyes on an application
Rick, I have fixed that error. Apparantly I was a little loose on how I was sending back errors. That has been standardized now, and errors should be working correctly (buh dum dum). Thanks, Paul Not being familiar with mssql (I'm a mysql user), I made some entry mistakes when trying to create a table. An error message would pop up identifying my mistake, but then when I clicked ok to go back and correct the error, the form for entering a column had disappeared. Is that supposed to happen? I would think that the alert would disappear, then the form would reappear. Rick (Sorry, forgot the demo URL...) I have created a test account with the following credentials: Demo URL: http://www.nucomsolutions.com/dbDiscover Server name: sql1100.shared-servers.com Port number: 1086 Username: hof_test Password: hof_test I'm not allowed to do anything with the user accounts or adding databases, since this is on a shared database hosting server. All interested are encouraged to play around and offer any feedback. Remember this is a work in progress, so a lot of functionality is yet to be added. Thanks, Paul Paul Day Owner/Principal Architect phone: 410.241.8465 email: p...@nucomsolutions.com web: http://www.nucomsolutions.com/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336897 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Creating a custom ajax error
Has anyone used cfhttp to throw an ajax error that returns a JSON object and error code 500? I'm looking for a code snippet of your onError() method. I'm using jQuery and am also trying to decide how to handle it on the client side. Specifically looking for when a session expires and when a server error occurs what to do on the client side (session expiration refreshes the page to login panel,etc). ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336898 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Creating a custom ajax error
There are a couple of ways you can do this. I'm going to do a blog entry on this in a few minutes with a full example, but, you can have logic like this: (pseudo-code obviously for this part) if I need to login: if ajax request, throw an exception with a specific message else redirect to login.cfm Then in your JS code, make use of the global Ajax object to see errors: $.ajaxSetup({ error:function(x,e){ if(x.status == 500 x.statusText == SessionTimeout) { alert(Your session has timed out.); location.href = 'index.cfm'; } } }); On Wed, Sep 8, 2010 at 10:45 AM, Tony Bentley cascadefreehee...@gmail.com wrote: Has anyone used cfhttp to throw an ajax error that returns a JSON object and error code 500? I'm looking for a code snippet of your onError() method. I'm using jQuery and am also trying to decide how to handle it on the client side. Specifically looking for when a session expires and when a server error occurs what to do on the client side (session expiration refreshes the page to login panel,etc). ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336899 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Creating a custom ajax error
That's exactly what I was looking for Ray. So the $.ajaxSetup() method handles the errors and redirects expired session. I knew there was a way to do this outside of my ajax requests but wasn't sure if I needed to create a proxy method or otherwise. Also, I noticed that you are expecting a string SessionTimeout which is exactly what I am doing, just not in the same place (hence asking for some advice since I am duplicating this all over the place). So this leaves me with another thought about passing the error back to the client. If a ColdFusion error occurs, I would really like to have a structure to work with but how would you identify that it indeed is a server error? I would want an indicator and a structure at the same timeor maybe you can advise this as well? Thanks for that snippet. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336900 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Creating a custom ajax error
Hmm. Good followup! So I'd say you would a) want to handle the issue for sure, but b) probably not tell the user too much. So assuming that you normally have an error handler that say something vague (or maybe it shows the full error, whatever, point is, you handle it), we need a version for Ajax too. Correct? (I think I just restated what you said - but want to ensure we are on the same page. On Wed, Sep 8, 2010 at 12:04 PM, Tony Bentley cascadefreehee...@gmail.com wrote: That's exactly what I was looking for Ray. So the $.ajaxSetup() method handles the errors and redirects expired session. I knew there was a way to do this outside of my ajax requests but wasn't sure if I needed to create a proxy method or otherwise. Also, I noticed that you are expecting a string SessionTimeout which is exactly what I am doing, just not in the same place (hence asking for some advice since I am duplicating this all over the place). So this leaves me with another thought about passing the error back to the client. If a ColdFusion error occurs, I would really like to have a structure to work with but how would you identify that it indeed is a server error? I would want an indicator and a structure at the same timeor maybe you can advise this as well? Thanks for that snippet. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336901 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
Any advantage to one over the other? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336902 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
With SQL Server, DEFINITELY go with left(str, 4) = 'string' It has much less processing overhead. -Original Message- From: Michael Grant [mailto:mgr...@modus.bz] Sent: Wednesday, September 08, 2010 1:20 PM To: cf-talk Subject: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%' Any advantage to one over the other? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336903 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
What about mySQL? Do you know if this is documented and easy to find? On Wed, Sep 8, 2010 at 1:23 PM, DURETTE, STEVEN J (ATTASIAIT) sd1...@att.com wrote: With SQL Server, DEFINITELY go with left(str, 4) = 'string' It has much less processing overhead. -Original Message- From: Michael Grant [mailto:mgr...@modus.bz] Sent: Wednesday, September 08, 2010 1:20 PM To: cf-talk Subject: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%' Any advantage to one over the other? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336904 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Creating a custom ajax error
FYI, blog entry on the work so far: http://www.coldfusionjedi.com/index.cfm/2010/9/8/Example-of-handling-session-time-outs-in-an-Ajax-application On Wed, Sep 8, 2010 at 12:16 PM, Raymond Camden rcam...@gmail.com wrote: Hmm. Good followup! So I'd say you would a) want to handle the issue for sure, but b) probably not tell the user too much. So assuming that you normally have an error handler that say something vague (or maybe it shows the full error, whatever, point is, you handle it), we need a version for Ajax too. Correct? (I think I just restated what you said - but want to ensure we are on the same page. On Wed, Sep 8, 2010 at 12:04 PM, Tony Bentley cascadefreehee...@gmail.com wrote: That's exactly what I was looking for Ray. So the $.ajaxSetup() method handles the errors and redirects expired session. I knew there was a way to do this outside of my ajax requests but wasn't sure if I needed to create a proxy method or otherwise. Also, I noticed that you are expecting a string SessionTimeout which is exactly what I am doing, just not in the same place (hence asking for some advice since I am duplicating this all over the place). So this leaves me with another thought about passing the error back to the client. If a ColdFusion error occurs, I would really like to have a structure to work with but how would you identify that it indeed is a server error? I would want an indicator and a structure at the same timeor maybe you can advise this as well? Thanks for that snippet. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336905 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Creating a custom ajax error
You're correct if the application was something on the public end but during black box testing is when this would be useful. Before go-live I would like the user (or another client based delivery system) to catch errors and pass them back to a ticket. I can then go into my error log files and see more detail of what happened or get a little more information about how to duplicate and resolve the issue. Following, I would return something vague once black box testing is complete like 'were sorry an error has occurred' and then refresh or catch it and move on, etc. So to join the two, the real answer is yes and yes :) I would want to say whatever I want and handle it however I want based on when in the SDLC it is occurring and who is getting the error. Thanks for helping me on this. I know there are a lot of ways to do it but that's my problem. I think there is probably a better solution specific to CF/JQuery, perhaps the most common client/server combination for ColdFusion. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336906 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
On Wed, Sep 8, 2010 at 1:27 PM, Michael Grant mgr...@modus.bz wrote: What about mySQL? Do you know if this is documented and easy to find? http://dev.mysql.com/doc/refman/5.6/en/mysql-indexes.html ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336907 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Creating a custom ajax error
So I plan a blog entry on this, but taking my example of ajaxSetup: $.ajaxSetup({ error:function(x,e){ if(x.status == 500 x.statusText == SessionTimeout) { alert(Your session has timed out.); location.href = 'login.cfm'; } } }); I'd simply add an else to the IF there to do X,where X is either the vague handler or the more verbose one you spoke of. On Wed, Sep 8, 2010 at 1:00 PM, Tony Bentley cascadefreehee...@gmail.com wrote: You're correct if the application was something on the public end but during black box testing is when this would be useful. Before go-live I would like the user (or another client based delivery system) to catch errors and pass them back to a ticket. I can then go into my error log files and see more detail of what happened or get a little more information about how to duplicate and resolve the issue. Following, I would return something vague once black box testing is complete like 'were sorry an error has occurred' and then refresh or catch it and move on, etc. So to join the two, the real answer is yes and yes :) I would want to say whatever I want and handle it however I want based on when in the SDLC it is occurring and who is getting the error. Thanks for helping me on this. I know there are a lot of ways to do it but that's my problem. I think there is probably a better solution specific to CF/JQuery, perhaps the most common client/server combination for ColdFusion. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336908 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
turn on debug mode, run both versions and then look at the execution time of the cfquery, this will show you which processed faster. On Wed, Sep 8, 2010 at 7:11 PM, Won Lee won...@gmail.com wrote: On Wed, Sep 8, 2010 at 1:27 PM, Michael Grant mgr...@modus.bz wrote: tioin What about mySQL? Do you know if this is documented and easy to find? http://dev.mysql.com/doc/refman/5.6/en/mysql-indexes.html ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336909 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Creating a custom ajax error
This is what I got from today's lesson ... Application.cfc - OnError: cffunction name=onError access=public cfargument name=exception required=true cfargument name=EventName type=String required=true !---if the request is ajax, throw an error that can be returned to the client in a basic string and then log the error as usual--- cfif StructKeyExists(requestHeaders, X-Requested-With) and StructFind(requestHeaders,X-Requested-With) eq XMLHttpRequest cfthrow errorcode=500 message=ColdFusion Error cfelse cfdump var=#arguments.exception# /cfif /cffunction Client side script: $.ajaxSetup({ error:function(x,e){ if(x.status == 500 x.statusText == SessionTimeout) { alert(Your session has timed out.); location.href = 'login.cfm'; } else if(x.status == 500 x.statusText == ColdFusion Error){ alert(x.statusText);//test for coldfusion error } } }); Thanks Ray. This is what I needed today. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336910 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
Great suggestion. Thanks. On Wed, Sep 8, 2010 at 2:26 PM, Russ Michaels r...@michaels.me.uk wrote: turn on debug mode, run both versions and then look at the execution time of the cfquery, this will show you which processed faster. On Wed, Sep 8, 2010 at 7:11 PM, Won Lee won...@gmail.com wrote: On Wed, Sep 8, 2010 at 1:27 PM, Michael Grant mgr...@modus.bz wrote: tioin What about mySQL? Do you know if this is documented and easy to find? http://dev.mysql.com/doc/refman/5.6/en/mysql-indexes.html ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336911 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Creating a custom ajax error
My post above is wrong. Here is what I wanted to happen: cffunction name=onError access=public cfargument name=exception required=true cfargument name=EventName type=String required=true !---if the request is ajax, throw an error that can be returned to the client in a basic string and then log the error as usual--- cfif StructKeyExists(requestHeaders, X-Requested-With) and StructFind(requestHeaders,X-Requested-With) eq XMLHttpRequest cfdump var=#arguments.exception# cfheader statusCode=500 statusText=ColdFusion Error cfelse cfdump var=#arguments.exception# /cfif /cffunction This throws the error and dumps it out in html for firebug but ajaxSetup() now knows what to do with it based on x.status == 500 x.statusText==ColdFusion Error. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336912 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
In SQL Server go with like str%. The reason is that like str% is sargable and functions are not. Functions also have overhead that native set-based SQL does not. I would assume the same is true with mySQL. Native SQL is usually faster than functions as a general rule, unless the equivalent SQL is wildly complex relative to what the function is doing for you. -Mike Chabot On Wed, Sep 8, 2010 at 1:27 PM, Michael Grant mgr...@modus.bz wrote: What about mySQL? Do you know if this is documented and easy to find? On Wed, Sep 8, 2010 at 1:23 PM, DURETTE, STEVEN J (ATTASIAIT) sd1...@att.com wrote: With SQL Server, DEFINITELY go with left(str, 4) = 'string' It has much less processing overhead. -Original Message- From: Michael Grant [mailto:mgr...@modus.bz] Sent: Wednesday, September 08, 2010 1:20 PM To: cf-talk Subject: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%' Any advantage to one over the other? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336913 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
Hmmm. That seems to conflict with what Steven says. Perhaps a blood match is in order? On Wed, Sep 8, 2010 at 3:10 PM, Mike Chabot mcha...@gmail.com wrote: In SQL Server go with like str%. The reason is that like str% is sargable and functions are not. Functions also have overhead that native set-based SQL does not. I would assume the same is true with mySQL. Native SQL is usually faster than functions as a general rule, unless the equivalent SQL is wildly complex relative to what the function is doing for you. -Mike Chabot On Wed, Sep 8, 2010 at 1:27 PM, Michael Grant mgr...@modus.bz wrote: What about mySQL? Do you know if this is documented and easy to find? On Wed, Sep 8, 2010 at 1:23 PM, DURETTE, STEVEN J (ATTASIAIT) sd1...@att.com wrote: With SQL Server, DEFINITELY go with left(str, 4) = 'string' It has much less processing overhead. -Original Message- From: Michael Grant [mailto:mgr...@modus.bz] Sent: Wednesday, September 08, 2010 1:20 PM To: cf-talk Subject: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%' Any advantage to one over the other? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336914 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
Well, I have to apologize! I am going through some training right now that is telling me exactly that. I was always told before that using like was bad, but apparently it is better. Steve -Original Message- From: Mike Chabot [mailto:mcha...@gmail.com] Sent: Wednesday, September 08, 2010 3:10 PM To: cf-talk Subject: Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%' In SQL Server go with like str%. The reason is that like str% is sargable and functions are not. Functions also have overhead that native set-based SQL does not. I would assume the same is true with mySQL. Native SQL is usually faster than functions as a general rule, unless the equivalent SQL is wildly complex relative to what the function is doing for you. -Mike Chabot On Wed, Sep 8, 2010 at 1:27 PM, Michael Grant mgr...@modus.bz wrote: What about mySQL? Do you know if this is documented and easy to find? On Wed, Sep 8, 2010 at 1:23 PM, DURETTE, STEVEN J (ATTASIAIT) sd1...@att.com wrote: With SQL Server, DEFINITELY go with left(str, 4) = 'string' It has much less processing overhead. -Original Message- From: Michael Grant [mailto:mgr...@modus.bz] Sent: Wednesday, September 08, 2010 1:20 PM To: cf-talk Subject: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%' Any advantage to one over the other? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336915 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
Or, if anyone really cares, just write both the queries, fire up the Query Profiler (for MSSQL) and see what the execution plans say. On Wed, Sep 8, 2010 at 12:12 PM, Michael Grant mgr...@modus.bz wrote: Hmmm. That seems to conflict with what Steven says. Perhaps a blood match is in order? On Wed, Sep 8, 2010 at 3:10 PM, Mike Chabot mcha...@gmail.com wrote: In SQL Server go with like str%. The reason is that like str% is sargable and functions are not. Functions also have overhead that native set-based SQL does not. I would assume the same is true with mySQL. Native SQL is usually faster than functions as a general rule, unless the equivalent SQL is wildly complex relative to what the function is doing for you. -Mike Chabot On Wed, Sep 8, 2010 at 1:27 PM, Michael Grant mgr...@modus.bz wrote: What about mySQL? Do you know if this is documented and easy to find? On Wed, Sep 8, 2010 at 1:23 PM, DURETTE, STEVEN J (ATTASIAIT) sd1...@att.com wrote: With SQL Server, DEFINITELY go with left(str, 4) = 'string' It has much less processing overhead. -Original Message- From: Michael Grant [mailto:mgr...@modus.bz] Sent: Wednesday, September 08, 2010 1:20 PM To: cf-talk Subject: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%' Any advantage to one over the other? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336916 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Creating a custom ajax error
Remove the dump perhaps. On Wed, Sep 8, 2010 at 1:58 PM, Tony Bentley cascadefreehee...@gmail.com wrote: My post above is wrong. Here is what I wanted to happen: cffunction name=onError access=public cfargument name=exception required=true cfargument name=EventName type=String required=true !---if the request is ajax, throw an error that can be returned to the client in a basic string and then log the error as usual--- cfif StructKeyExists(requestHeaders, X-Requested-With) and StructFind(requestHeaders,X-Requested-With) eq XMLHttpRequest cfdump var=#arguments.exception# cfheader statusCode=500 statusText=ColdFusion Error cfelse cfdump var=#arguments.exception# /cfif /cffunction This throws the error and dumps it out in html for firebug but ajaxSetup() now knows what to do with it based on x.status == 500 x.statusText==ColdFusion Error. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336917 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
mike, Please let us know what you find out. I'm very curious of this myself. As the document clearly states, mysql will use an index when you use a like but don't start the string with a wildcard. So we know that Left(str,5) = 'string' VS WHERE str LIKE 'string%'both will use an index. The question now becomes the cost of using LEFT vs using the LIKE. BTW, I assume you meant where left(str, 6) = 'string'. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336918 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
Yes I did. Apparently I can't count. :D On Wed, Sep 8, 2010 at 3:45 PM, Won Lee won...@gmail.com wrote: mike, Please let us know what you find out. I'm very curious of this myself. As the document clearly states, mysql will use an index when you use a like but don't start the string with a wildcard. So we know that Left(str,5) = 'string' VS WHERE str LIKE 'string%'both will use an index. The question now becomes the cost of using LEFT vs using the LIKE. BTW, I assume you meant where left(str, 6) = 'string'. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336919 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Preserve HTML format when inserting into HTML
But like I said earlier, I created a workaround so I'm not stressing about it. It's just odd. I have found the same problem with a different XML file. I am going to try to put together a proof of concept to see if other people besides me can recreate this issue. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336920 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Preserve HTML format when inserting into HTML
Ok, guys, I have a working proof of concept. At least on my server, this simple 4 line code example illustrates the problem. To recreate, dowload this file: http://techfeed.net/xmlHTMLTest.zip And then follow these steps. 1. Extract the zip to your ColdFusion sites directory. 2. BEFORE RUNNING THE .CFM, open up parkRegions.xml and note how the first region has normal (not escaped) HTML tags. 3. Run xmlHTMLTest.cfm (no output is generated, so you'll just see a blank page). 4. Open parkRegions.xml again and note how the first region now contains escaped HTML. At least, for me on my servers it does (I tried this code on two different servers). Can you see what I'm doing wrong? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336921 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Preserve HTML format when inserting into HTML
Ray, In addition to my previous email with proof of concept code, I am able to reproduce my problem using your code below by adding this cffile tag to the end of your code: cffile action=write file=#expandPath('foo.xml')# output=#toString(x)# Weird. I can't reproduce this: cfset s = font color=redbfoo/b/font cfxml variable=x root child name=one / /root /cfxml cfset x.root.child[1].xmlText = s cfoutput #x.root.child[1].xmltext# p #s# /cfoutput The value is NOT escaped in the XML, nor in the original variable. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336922 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
Getting to actually test this hasn't been as easy as I'd hoped. If I can get something definitive I'll post. On Wed, Sep 8, 2010 at 3:45 PM, Won Lee won...@gmail.com wrote: mike, Please let us know what you find out. I'm very curious of this myself. As the document clearly states, mysql will use an index when you use a like but don't start the string with a wildcard. So we know that Left(str,5) = 'string' VS WHERE str LIKE 'string%'both will use an index. The question now becomes the cost of using LEFT vs using the LIKE. BTW, I assume you meant where left(str, 6) = 'string'. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336923 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Problem opening a CF created .XLS in OpenOffice.
I have created a cfc that you pass in queries and get back an xls with multiple worksheets. This seems to work great and opens perfectly in Microsoft Excel. However if I open it in OpenOffice I get a screen telling me it's importing text and asks me to choose the language. Then the content of the document is actually just the XML markup as plain text within two cells. Anyone ever experienced this before? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336924 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Preserve HTML format when inserting into HTML
I'm digging. This came up 3 years ago too: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32864 On Wed, Sep 8, 2010 at 4:54 PM, Jake Munson jmun...@idahopower.com wrote: Ray, In addition to my previous email with proof of concept code, I am able to reproduce my problem using your code below by adding this cffile tag to the end of your code: cffile action=write file=#expandPath('foo.xml')# output=#toString(x)# Weird. I can't reproduce this: cfset s = font color=redbfoo/b/font cfxml variable=x root child name=one / /root /cfxml cfset x.root.child[1].xmlText = s cfoutput #x.root.child[1].xmltext# p #s# /cfoutput The value is NOT escaped in the XML, nor in the original variable. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336925 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Preserve HTML format when inserting into HTML
Woot! Found it: http://www.mail-archive.com/cf-talk@houseoffusion.com/msg312892.html I have _never_ seen this in use, but it works perfectly: cfset s = font color=redbfoo/b/font cfxml variable=x root child name=one / /root /cfxml cfdump var=#x# cfset x.root.child[1].xmlCData = s cfoutput #x.root.child[1].xmltext# p #s# /cfoutput cffile action=write file=#expandPath('foo.xml')# output=#toString(x)# On Wed, Sep 8, 2010 at 8:38 PM, Raymond Camden rcam...@gmail.com wrote: I'm digging. This came up 3 years ago too: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32864 On Wed, Sep 8, 2010 at 4:54 PM, Jake Munson jmun...@idahopower.com wrote: Ray, In addition to my previous email with proof of concept code, I am able to reproduce my problem using your code below by adding this cffile tag to the end of your code: cffile action=write file=#expandPath('foo.xml')# output=#toString(x)# Weird. I can't reproduce this: cfset s = font color=redbfoo/b/font cfxml variable=x root child name=one / /root /cfxml cfset x.root.child[1].xmlText = s cfoutput #x.root.child[1].xmltext# p #s# /cfoutput The value is NOT escaped in the XML, nor in the original variable. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336926 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: WHERE Left(str,5) = 'string' VS WHERE str LIKE 'string%'
I ran a quick test CREATE TABLE HoF ( ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, LastName VARCHAR(100) ) ENGINE = InnoDB; insert into HoF (LastName) values ('Smith'); insert into HoF (LastName) values ('Smithville'); insert into HoF (LastName) values ('Jones'); insert into HoF (LastName) values ('Smithy'); insert into HoF (LastName) values ('Smit'); select lastname from HoF where left(lastname, 5) = 'smith'; select lastname from HoF where lastname like 'smith%'; explain extended select lastname from HoF where left(lastname, 5) = 'smith'; explain extended select lastname from HoF where lastname like 'smith%'; create index lname_index on HoF (lastname(100)); explain extended select lastname from HoF where left(lastname, 5) = 'smith'; explain extended select lastname from HoF where lastname like 'smith%'; Conclusion, which seems pretty obvious now, is that Like is the better route. LEFT will have to read every row so it can execute the LEFT function against it while the LIKE column will filter out columns that it doesn't meet the condition. It's really late and I had a tough day at work so please correct me if anyone sees anything wrong with my analysis. W ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336927 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm