RE: There's got to be a way around this
There are generally two reasons for something like that: 1) The code is very old - we've still got code from CF 2.0 around and it's pretty damn nasty. ;^) A lot of the stuff we take for granted (structs, scopes as structs, even arrays) didn't exist in earlier versions of the language. In this case, I don't think that's an excuse, since CF has had FORM.FIELDNAMES since CF 2.0, at least. That's what it was there for - to let you get a list of the form fields so you could process them. Now, of course, we have the Form scope exposed as a structure, which is nicer, but the required functionality for generalized form handlers has been there all the time. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207523 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: There's got to be a way around this
I'm not sure what you're asking and want to be. Ben and Isaac (a biblical sounding pair if ever I've heard one) have already shown you several methods for accessing arbitrary form fields. My confusion is your mention of CFPARAM. CFPARAM has nothing specifically to do with Forms - it's there to provide default values for known variables that may, for some reason, not be received. Its most often used for the FORM and URL scopes but can be used for any scope at all. I was confused by this at first and thought wat I was reading about PHP was a description of a pre-generated array containing an array of any possible combination of characters of any length, starting with A and ending with an indeterminate number of extended ascii characters... Then it dawned on me that he probably hadn't discovered the form scope yet and was doing something like this: cfparam name=x default= instead of this: cfparam name=form.x default= I'm still not entirely certain how that comes across as the question he asked, except perhaps that he's trying to scope his variables as say variables.x instead of form.x without first copying them down from the form scope into the variables scope, so the server produces an error when it doesn't see variables.firstname even though the firstname input element was a text input. I'm trying to remember if cfparam name=x default= inserts a value into the variables scope if there's a form field matching that variable name... It's been so long since I've used cfparam without scoping the name that I can't remember what the behavior is. s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.fusiontap.com http://coldfusion.sys-con.com/author/4806Dealey.htm ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207524 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: There's got to be a way around this
On Tuesday 24 May 2005 06:54, S. Isaac Dealey wrote: cfparam name=x default= instead of this: cfparam name=form.x default= I'm still not entirely certain how that comes across as the question he asked, except perhaps that he's trying to scope his variables as say variables.x instead of form.x without first copying them down from the form scope into the variables scope, so the server produces an error when it doesn't see variables.firstname even though the firstname input element was a text input. I'm trying to remember if cfparam name=x default= inserts a value into the variables scope if there's a form field matching that variable name... It's been so long since I've used cfparam without scoping the name that I can't remember what the behavior is. Sort of. I don't want to have to include the cfparam line at all, though, since there are so many times when I won't know what parameters are going to be used in a page at the tim that I write it -- such as when a form has been dynamically generated and can contain different fields each time it is generated, based on user input or results from a database query. -- Richard S. Crawford http://www.mossroot.com -- Richard S. Crawford Programmer III UC Davis Extension Distance Education Group 2901 K Street Sacramento, CA 95816 (916)327-7793 http://unexdlc.ucdavis.edu ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207530 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: There's got to be a way around this
On Monday 23 May 2005 22:03, Jim Davis wrote: The developer in question used it as an example of how hard it was to do simple things in CF compared to Java in meeting. I wrote #listfirst(var, -)# and #listlast(var, -)# on the whiteboard. ;^) In general, I prefer to program in PHP since I feel like I have much more control over the code in PHP than I do in Cold Fusion. However, I have come to appreciate CF more over the past few months as I've learned that the code that I've been working with around here is not typical of the kind of code that CF professionals generally produce. -- Richard S. Crawford Programmer III UC Davis Extension Distance Education Group 2901 K Street Sacramento, CA 95816 (916)327-7793 http://unexdlc.ucdavis.edu ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207532 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: There's got to be a way around this
On Tuesday 24 May 2005 06:54, S. Isaac Dealey wrote: cfparam name=x default= instead of this: cfparam name=form.x default= I'm still not entirely certain how that comes across as the question he asked, except perhaps that he's trying to scope his variables as say variables.x instead of form.x without first copying them down from the form scope into the variables scope, so the server produces an error when it doesn't see variables.firstname even though the firstname input element was a text input. I'm trying to remember if cfparam name=x default= inserts a value into the variables scope if there's a form field matching that variable name... It's been so long since I've used cfparam without scoping the name that I can't remember what the behavior is. Sort of. I don't want to have to include the cfparam line at all, though, since there are so many times when I won't know what parameters are going to be used in a page at the tim that I write it -- such as when a form has been dynamically generated and can contain different fields each time it is generated, based on user input or results from a database query. Okay... now I'm lost... How does PHP obviate the need to parameterize variables on a form action page?Does it do something like ASP where any undefined variable is equal to instead of producing an error? s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.fusiontap.com http://coldfusion.sys-con.com/author/4806Dealey.htm ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207534 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: There's got to be a way around this
-Original Message- From: Richard Crawford [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 24, 2005 12:30 PM To: CF-Talk Subject: Re: There's got to be a way around this On Monday 23 May 2005 22:03, Jim Davis wrote: The developer in question used it as an example of how hard it was to do simple things in CF compared to Java in meeting. I wrote #listfirst(var, -)# and #listlast(var, -)# on the whiteboard. ;^) In general, I prefer to program in PHP since I feel like I have much more control over the code in PHP than I do in Cold Fusion. However, I have come to appreciate CF more over the past few months as I've learned that the code that I've been working with around here is not typical of the kind of code that CF professionals generally produce. The one everlasting rule of thumb is that you can produce complete crap using any language. ;^) There's absolutely nothing wrong with having a favorite. Personally I don't see any of the languages as being head-and-shoulders above the others. I'll never have a problem with anybody saying they prefer one language over another. I just know that I can code most things cleaner and quicker in CF. I generally won't comment on how easy or hard another language is (especially one that I barely know). In my company however this is the norm: we moved away from CF almost purely on the say-so of the Java programmers like the one I mentioned and their assertions that Java was easier to work with. In short they produced complete crap and blamed the language. Sounds like you're working with the results of that kind of thinking. ;^) Jim Davis ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207542 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: There's got to be a way around this
On Tuesday 24 May 2005 10:12, Jim Davis wrote: In my company however this is the norm: we moved away from CF almost purely on the say-so of the Java programmers like the one I mentioned and their assertions that Java was easier to work with. In short they produced complete crap and blamed the language. Sounds like you're working with the results of that kind of thinking. ;^) I tend to agree with you on the whole, though I think I will be spending several days trying to get my head around the idea that Java is easier than anything. I've never been able to figure Java out. -- Richard S. Crawford Programmer III UC Davis Extension Distance Education Group 2901 K Street Sacramento, CA 95816 (916)327-7793 http://unexdlc.ucdavis.edu ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207557 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: There's got to be a way around this
On Tuesday 24 May 2005 10:12, Jim Davis wrote: In my company however this is the norm: we moved away from CF almost purely on the say-so of the Java programmers like the one I mentioned and their assertions that Java was easier to work with. In short they produced complete crap and blamed the language. Sounds like you're working with the results of that kind of thinking. ;^) I tend to agree with you on the whole, though I think I will be spending several days trying to get my head around the idea that Java is easier than anything. I've never been able to figure Java out. These are the same sort of people who think that bitshrn() is easier to use than for instance find(R,mystring)... A project I worked on a while back the guy decided to use all bit-math for the security -- and I've seen several cases of using bit-math for permission-systems since then and every one of them has been attrocious. I remember the guy saying here I'll show you, it's real simple and then failing miserably to explain succinctly how it worked. s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.fusiontap.com http://coldfusion.sys-con.com/author/4806Dealey.htm ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207561 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
There's got to be a way around this
It seems that on every Cold Fusion page that processes variables from a previous page -- say a form and the page that processes the form -- every variable on the form must be accounted for. This is fine if the form is unchanging, but if the form is dynamic and might change every time it's loaded, the number and name of the variables that it passes to the processing page may change. In PHP you can cope with this quite nicely by directly accessing the HTTP_POST[] array, casting it to an object and looping through the properties, but I can't find a similar way to do that in Cold Fusion. In Cold Fusion, it looks like I have to use CFPARAM var=value for every single possible variable that might come from the form page. Is there a way around that? -- Richard S. Crawford Programmer III UC Davis Extension Distance Education Group 2901 K Street Sacramento, CA 95816 (916)327-7793 http://unexdlc.ucdavis.edu ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207495 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: There's got to be a way around this
FORM is a structure that contains all HTTP POST fields, and you can loop through it easily. --- Ben -Original Message- From: Richard Crawford [mailto:[EMAIL PROTECTED] Sent: Monday, May 23, 2005 9:15 PM To: CF-Talk Subject: There's got to be a way around this It seems that on every Cold Fusion page that processes variables from a previous page -- say a form and the page that processes the form -- every variable on the form must be accounted for. This is fine if the form is unchanging, but if the form is dynamic and might change every time it's loaded, the number and name of the variables that it passes to the processing page may change. In PHP you can cope with this quite nicely by directly accessing the HTTP_POST[] array, casting it to an object and looping through the properties, but I can't find a similar way to do that in Cold Fusion. In Cold Fusion, it looks like I have to use CFPARAM var=value for every single possible variable that might come from the form page. Is there a way around that? -- Richard S. Crawford Programmer III UC Davis Extension Distance Education Group 2901 K Street Sacramento, CA 95816 (916)327-7793 http://unexdlc.ucdavis.edu ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207497 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: There's got to be a way around this
It seems that on every Cold Fusion page that processes variables from a previous page -- say a form and the page that processes the form -- every variable on the form must be accounted for. This is fine if the form is unchanging, but if the form is dynamic and might change every time it's loaded, the number and name of the variables that it passes to the processing page may change. In PHP you can cope with this quite nicely by directly accessing the HTTP_POST[] array, casting it to an object and looping through the properties, but I can't find a similar way to do that in Cold Fusion. In Cold Fusion, it looks like I have to use CFPARAM var=value for every single possible variable that might come from the form page. Is there a way around that? Several... cfloop index=field list=#strutkeylist(form)#.../cfloop cfif structkeyexists(form,fieldname).../cfif cfloop index=field list=fielda,fieldb,fieldc cfparam name=form.#field# type=string default=/cfloop cfset structappend(form,url,false) (puts all url variables in the form scope without overwriting) s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.fusiontap.com http://coldfusion.sys-con.com/author/4806Dealey.htm ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207500 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: There's got to be a way around this
I forgot this one: cfloop item=field collection=#form#.../cfloop s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.fusiontap.com http://coldfusion.sys-con.com/author/4806Dealey.htm ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207501 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: There's got to be a way around this
-Original Message- From: Richard Crawford [mailto:[EMAIL PROTECTED] Sent: Monday, May 23, 2005 9:15 PM To: CF-Talk Subject: There's got to be a way around this In PHP you can cope with this quite nicely by directly accessing the HTTP_POST[] array, casting it to an object and looping through the properties, but I can't find a similar way to do that in Cold Fusion. In Cold Fusion, it looks like I have to use CFPARAM var=value for every single possible variable that might come from the form page. Is there a way around that? I'm not sure what you're asking and want to be. Ben and Isaac (a biblical sounding pair if ever I've heard one) have already shown you several methods for accessing arbitrary form fields. My confusion is your mention of CFPARAM. CFPARAM has nothing specifically to do with Forms - it's there to provide default values for known variables that may, for some reason, not be received. Its most often used for the FORM and URL scopes but can be used for any scope at all. CFPARAM creates variables that you need if they're not present (it can also test type) - it doesn't really seem appropriate at all in a situation where you don't know what's coming down the pipe. In effect CFPARAM is shorthand for this: cfif NOT IsDefined(Form.MyField) cfset Form.Myfield = MyDefaultValue / /cfif It seems to me like you might be under the impression that CFPARAM HAS to be used to access form variables and this just isn't the case. Any form fields passed to the page are present regardless of whether you use CFPARAM or not. Make sense? Am I missing the point? Jim Davis ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207503 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: There's got to be a way around this
On Monday 23 May 2005 18:22, Ben Forta wrote: FORM is a structure that contains all HTTP POST fields, and you can loop through it easily. Thanks! I'm trying to figure out some old code written by some previous developers, and they used some incredibly complicated tricks to deal with having to have all variables pre-defined, including a special stored procedure that creates a temporary file which contains all the fields... As you can imagine, it has a slight impact on performance. -- Richard S. Crawford Programmer III UC Davis Extension Distance Education Group 2901 K Street Sacramento, CA 95816 (916)327-7793 http://unexdlc.ucdavis.edu ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207504 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: There's got to be a way around this
-Original Message- From: Richard Crawford [mailto:[EMAIL PROTECTED] Sent: Monday, May 23, 2005 10:37 PM To: CF-Talk Subject: Re: There's got to be a way around this On Monday 23 May 2005 18:22, Ben Forta wrote: FORM is a structure that contains all HTTP POST fields, and you can loop through it easily. Thanks! I'm trying to figure out some old code written by some previous developers, and they used some incredibly complicated tricks to deal with having to have all variables pre-defined, including a special stored procedure that creates a temporary file which contains all the fields... As you can imagine, it has a slight impact on performance. There are generally two reasons for something like that: 1) The code is very old - we've still got code from CF 2.0 around and it's pretty damn nasty. ;^) A lot of the stuff we take for granted (structs, scopes as structs, even arrays) didn't exist in earlier versions of the language. (As a hint: if you see ParameterExists() in your code you know it's geriatric.) 2) The developers were very bad. Or, more specifically, very bad at CF. I've often wanted to start a worst code contest for people to post the worst of the worst that they come across. In my experience most of this is just a failure to skim the reference manual. I've got one block of code I save that's 15+ lines long: it pulls two values from a string formatted as agencynumber-agentnumber. The developer in question used it as an example of how hard it was to do simple things in CF compared to Java in meeting. I wrote #listfirst(var, -)# and #listlast(var, -)# on the whiteboard. ;^) Jim Davis ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207507 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54