Re: Is this acceptable or reasonable CFC usage?
Do you have enable session management checked in the ColdFusion admin on your production box, and session management enabled in your Application.cfc? Rick Faircloth wrote: > I'm trying to set session variables for login with the code below. > It works fine on my local dev pc, but on the production server, > no session variables are being set. Is the code below not appropriate? > > Thanks, > > Rick > > > > > >required="yes"> >required="yes"> > > > > select manager_id, email_address, password, > announcements, > res_announcements, rental_properties, > new_communities, agents, > featured_properties, open_houses, > local_websites, fort_stewart, > our_community, approved_cities, > site_managers > > fromsite_managers > where email_address = > '#arguments.email_address#' > and password = '#arguments.password#' > > > > > > > > >get_manager.announcements> >get_manager.res_announcements> >get_manager.rental_properties> >get_manager.new_communities> > >get_manager.featured_properties> > >get_manager.local_websites> > >get_manager.our_community> >get_manager.approved_cities> >get_manager.site_managers> > > > > > > > > > > > > > > > > > > > > > > > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317515 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Is this acceptable or reasonable CFC usage?
I'm trying to set session variables for login with the code below. It works fine on my local dev pc, but on the production server, no session variables are being set. Is the code below not appropriate? Thanks, Rick select manager_id, email_address, password, announcements, res_announcements, rental_properties, new_communities, agents, featured_properties, open_houses, local_websites, fort_stewart, our_community, approved_cities, site_managers fromsite_managers where email_address = '#arguments.email_address#' and password = '#arguments.password#' ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317510 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Trying to find a CFC
On Tuesday 06 Jan 2009, Bobby Tomato wrote: > cf_magicktag This was made by Alagad, who now appear to call the same thing: http://www.alagad.com/go/products-and-projects/image-component/alagad-image-component If you are on a new enough Adobe CF or one of the open source engines, you might be better just converting to the native functions. -- Tom Chiverton Helping to synergistically enhance interfaces This email is sent for and on behalf of Halliwells LLP. Halliwells LLP is a limited liability partnership registered in England and Wales under registered number OC307980 whose registered office address is at Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB. A list of members is available for inspection at the registered office together with a list of those non members who are referred to as partners. We use the word ?partner? to refer to a member of the LLP, or an employee or consultant with equivalent standing and qualifications. Regulated by the Solicitors Regulation Authority. CONFIDENTIALITY This email is intended only for the use of the addressee named above and may be confidential or legally privileged. If you are not the addressee you must not read it and must not use any information contained in nor copy it nor inform any person other than Halliwells LLP or the addressee of its existence or contents. If you have received this email in error please delete it and notify Halliwells LLP IT Department on 0870 365 2500. For more information about Halliwells LLP visit www.halliwells.com. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317504 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Can I invoke a cfc with a loop?
Ok I think it's working now for some reason. I'll do more tests. Thanks for the argument output snippet. >> Can i output the arguments passed to the cfc? > > > > > > > > > ... > > > >Jochem ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317503 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Can I invoke a cfc with a loop?
On Wed, Jan 7, 2009 at 8:34 AM, Torrent Girl wrote: > Can i output the arguments passed to the cfc? ... Jochem ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317502 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Can I invoke a cfc with a loop?
Ok you mean just output the form variables? They seem to be ok. The loop is working when I insert one record. It's the multi insert that is not working. >If you've got this: > > > component="XXX" > method="YYY" > returnvariable="ZZZ"> > value="#sessionRead.userID#"/> > . > >just change it to this: > > >ZZZ = XXX.YYY(#sessionRead.userId#, #i#) > > >> ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317501 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Can I invoke a cfc with a loop?
If you've got this: . just change it to this: ZZZ = XXX.YYY(#sessionRead.userId#, #i#) On Tue, Jan 6, 2009 at 11:45 PM, Torrent Girl wrote: > I've tried to output the arguments but don't know the syntax. > > Do you know? > > >>Then it's getting called successfully and your in-method checking is >>erroring. Probably have something wrong with the way you're >>extracting the dynamic arguments. But the CFINVOKE itself is working. >> Can you comment out the CFINVOKE and just CFOUTPUT the arguments that >>you're passing so you can inspect manually? >> >>cheers, >>barneyb >> >> >>> > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317500 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Can I invoke a cfc with a loop?
I've tried to output the arguments but don't know the syntax. Do you know? >Then it's getting called successfully and your in-method checking is >erroring. Probably have something wrong with the way you're >extracting the dynamic arguments. But the CFINVOKE itself is working. > Can you comment out the CFINVOKE and just CFOUTPUT the arguments that >you're passing so you can inspect manually? > >cheers, >barneyb > > >> ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317499 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Can I invoke a cfc with a loop?
Then it's getting called successfully and your in-method checking is erroring. Probably have something wrong with the way you're extracting the dynamic arguments. But the CFINVOKE itself is working. Can you comment out the CFINVOKE and just CFOUTPUT the arguments that you're passing so you can inspect manually? cheers, barneyb On Tue, Jan 6, 2009 at 11:32 PM, Torrent Girl wrote: > Invalid arguments passed - it's a custom error > > > > >>Should work just fine, CFINVOKE doesn't really care how it's called, >>just that it has the right attributes/arguments. What's the error >>you're getting? >> >>cheers, >>barneyb >> >> >>> > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317498 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Can I invoke a cfc with a loop?
Can i output the arguments passed to the cfc? >Should work just fine, CFINVOKE doesn't really care how it's called, >just that it has the right attributes/arguments. What's the error >you're getting? > >cheers, >barneyb > > >> ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317497 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Can I invoke a cfc with a loop?
Invalid arguments passed - it's a custom error >Should work just fine, CFINVOKE doesn't really care how it's called, >just that it has the right attributes/arguments. What's the error >you're getting? > >cheers, >barneyb > > >> ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317496 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Can I invoke a cfc with a loop?
Should work just fine, CFINVOKE doesn't really care how it's called, just that it has the right attributes/arguments. What's the error you're getting? cheers, barneyb On Tue, Jan 6, 2009 at 11:28 PM, Torrent Girl wrote: > I am trying it an it's not working. > > Here is a snippett. Is this possible? > > I am looping over form fields and trying to invoke the cfc for each item in > the list. > > > component="X" >method="XXX" >returnvariable="X"> > value="#sessionRead.userID#"/> > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317495 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Can I invoke a cfc with a loop?
I am trying it an it's not working. Here is a snippett. Is this possible? I am looping over form fields and trying to invoke the cfc for each item in the list. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317494 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Trying to find a CFC
I'm helping a friend migrate a site over to a new host, and the old host is being very uncooperative. We seem to be missing a couple of CFC's. The most important one is cf_magicktag. I've seen it discussed on different boards, but I'm having trouble finding this online. Can anyone help? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317476 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Return JSON from a CFC
Um, JSON _is_ a string. It's not an object until the front end evaluates the string. jQuery can handle all of that for you though. Also, you used format=json. You need to use returnFormat. On Tue, Jan 6, 2009 at 8:44 AM, Joe wrote: > I just tried it and my CFC is still returning the JSON content but it seems > like it still appears to be a string rather than an object. I'm using this: > >//var wsURL = > '/ws/emp.cfc?method=getEmpInfo&returnFormat=json&searchParam=101'; >var wsURL = > 'http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any > &format=json&jsoncallback=?'; >$.getJSON(wsURL, >function(jsondata) { >// fnPopEmpList(jsondata); >alert(jsondata); >alert(jsondata.items[1].tags); >// $.each(jsondata.items, > function(i,item){ >// alert(item); >// }); >} >); > > When I use Flickr, alert(jsondata) displays [object Object] and I can access > elements like array notes; when I use my CFC alert(jsondata) displays a > string and trying to access elements results in "undefined". > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317455 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Return JSON from a CFC
You can do something like this, have your Jquery call a CFM page that calls the CFC component. $(document).ready(function() { // Call Ajax - $.ajax({ type: "POST", url: "act_Call_StatesCities.cfm", // dataType: "json", beforeSend: function(XMLHttpRequest) { // alert("beforeSend"); $("#loading").show(); this; // the options for this ajax request }, success: function(responseText){ alert(responseText); }, error: function(XMLHttpRequest, textStatus, errorThrown) { // typically only one of textStatus or errorThrown // will have info alert("Error - " + textStatus); this; // the options for this ajax request } }); }); odata = createObject("component","CFC/rt_StatesCities"); thedata = odata.fullJson(); WriteOutPut(thedata); Hope this helps. Thanks Mike Hughes michael.t.hug...@gmail.com On Tue, Jan 6, 2009 at 8:51 AM, Cutter (CFRelated) < cold.fus...@cutterscrossing.com> wrote: > Yes, it can. In your Ajax call parameters include returnFormat:'JSON', > and ColdFusion will automatically serialize your function's return as a > JSON object. > > Steve "Cutter" Blades > Adobe Certified Professional > Advanced Macromedia ColdFusion MX 7 Developer > > Co-Author of "Learning Ext JS" > http://www.packtpub.com/learning-ext-js/book > _ > http://blog.cutterscrossing.com > > Joe wrote: > > The reason I'm making a web service is b/c I want the JSON to be parsed > by > > jQuery. Are you telling me client-side Javascript can handle CFCs? > > > > > > > > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317451 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Return JSON from a CFC
Yes, it can. In your Ajax call parameters include returnFormat:'JSON', and ColdFusion will automatically serialize your function's return as a JSON object. Steve "Cutter" Blades Adobe Certified Professional Advanced Macromedia ColdFusion MX 7 Developer Co-Author of "Learning Ext JS" http://www.packtpub.com/learning-ext-js/book _ http://blog.cutterscrossing.com Joe wrote: > The reason I'm making a web service is b/c I want the JSON to be parsed by > jQuery. Are you telling me client-side Javascript can handle CFCs? > > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317450 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Return JSON from a CFC
I just tried it and my CFC is still returning the JSON content but it seems like it still appears to be a string rather than an object. I'm using this: //var wsURL = '/ws/emp.cfc?method=getEmpInfo&returnFormat=json&searchParam=101'; var wsURL = 'http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any &format=json&jsoncallback=?'; $.getJSON(wsURL, function(jsondata) { // fnPopEmpList(jsondata); alert(jsondata); alert(jsondata.items[1].tags); // $.each(jsondata.items, function(i,item){ // alert(item); // }); } ); When I use Flickr, alert(jsondata) displays [object Object] and I can access elements like array notes; when I use my CFC alert(jsondata) displays a string and trying to access elements results in "undefined". Subject: Return JSON from a CFC From: Raymond Camden Date: Mon, 5 Jan 2009 21:13:26 -0600 Thread: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:58433#317442 > The reason I'm making a web service is b/c I want the JSON to be > parsed by jQuery. Are you telling me client-side Javascript can handle CFCs? jQuery doesn't read WSDL (afaik). Therefore - you don't want a WSDL response. You want a JSON response. You can call any CFC, under web root, with just the url. Try it. Put this CFC under your web root: If you name this test.cfc, and put it in web root, open your browser to: http://yourhost/test.cfc?method=sayHi You wlll see a response. If you view source, you will see it is XML, in this case, WDDX. To switch to JSON, do: http://yourhost/test.cfc?method=sayHi&returnFormat=json Any CFC under web root, and any method with access=remote, can be directly called by your ajax code. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317449 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Return JSON from a CFC
On Mon, Jan 5, 2009 at 9:00 PM, Joe wrote: > The reason I'm making a web service is b/c I want the JSON to be parsed by > jQuery. Are you telling me client-side Javascript can handle CFCs? jQuery doesn't read WSDL (afaik). Therefore - you don't want a WSDL response. You want a JSON response. You can call any CFC, under web root, with just the url. Try it. Put this CFC under your web root: If you name this test.cfc, and put it in web root, open your browser to: http://yourhost/test.cfc?method=sayHi You wlll see a response. If you view source, you will see it is XML, in this case, WDDX. To switch to JSON, do: http://yourhost/test.cfc?method=sayHi&returnFormat=json Any CFC under web root, and any method with access=remote, can be directly called by your ajax code. > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317442 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Return JSON from a CFC
The reason I'm making a web service is b/c I want the JSON to be parsed by jQuery. Are you telling me client-side Javascript can handle CFCs? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317441 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Return JSON from a CFC
You don't want to call your local CFC with ?wsdl. That's the web service URL. You want to just call the CFC with it's normal name, and pass the method and the returnFormat argument. So your url should be something like: url="my.cfc?method=somemethod&returnformat=json" This will run the somemethod function of my.cfc and tell CFC to format the result into json. You don' t have to create the JSON yourself. Assuming you are using CF8 of course. On Mon, Jan 5, 2009 at 3:50 PM, Judah McAuley wrote: > I recall reading a blog posting that mentioned that CF returns > non-standard JSON by default. Its a more compact design but required a > custom data reader for the Ext library. While that isn't jQuery, it > might help you to your goal: > > http://blog.cutterscrossing.com/index.cfm/2008/11/20/ColdFusion-Query-Json-Data-Reader > > Judah > > On Mon, Jan 5, 2009 at 11:42 AM, Joe wrote: >> All, ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317438 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Return JSON from a CFC
I recall reading a blog posting that mentioned that CF returns non-standard JSON by default. Its a more compact design but required a custom data reader for the Ext library. While that isn't jQuery, it might help you to your goal: http://blog.cutterscrossing.com/index.cfm/2008/11/20/ColdFusion-Query-Json-Data-Reader Judah On Mon, Jan 5, 2009 at 11:42 AM, Joe wrote: > All, > > I recently created a small CFC returning query results in JSON format. The > querying works, the regular CF page is able to call the CFC as a WSDL page > properly passing params, and I am getting back JSON-like content. However I > have been unable to parse the JSON content like an array within jQuery. I > put the JSON variable inside an alert function in the CF page and I got a > JSON-like string. > > I then replaced the web service URL in my CF page with the one from the > following page: > http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback > When I reloaded the same CF page I got "[object Object]" and I was able to > parse the results from that web service. So it seems like I'm missing > something in my CFC that turns my JSON content into an object. I hope it's > something obvious... > > My code is as follows: > > == > Component: > > > > access="remote"> > > > > returnFormat="json" output="no"> > > > >strQuery = "SELECT empname, oprid , str(emplid) as emplid FROM > cae_alionOrgByUser where 1=1"; > >// "structKeyExists" is needed to use REFind >if ( (structKeyExists(arguments,"searchparam") eq "Yes") AND > (searchparam neq "") ) { > if (REFind("[A-Za-z\.]+", searchparam) gt 0) { > strQuery = strQuery & " and oprid like '%#searchparam#%'"; > } > if (REFind("\d+", searchparam) gt 0) { > strQuery = strQuery & " and emplid like '%#searchparam#%'"; > } >} > >strQuery = strQuery & " ORDER BY empname"; > > > > > #preservesinglequotes(strQuery)# > > > > > > > > > > > > > > > == > CF page: JavaScript > > var wsURL = '/ws/emp.cfc?wsdl'; > // var wsURL = > 'http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any > &format=json&jsoncallback=?'; > $.getJSON(wsURL, { >method: 'getEmpInfo', >searchParam: '101' >}, >function(jsondata) { > alert(jsondata); > alert(jsondata.DATA); > // alert(jsondata.title); > // $.each(jsondata.items, function(i,item){ > // alert(item); > // }); >} > ); > > == > > tia, > > - Joe > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317427 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Return JSON from a CFC
Ok, first of all to get the obligatory warning out of the way.. you need to be careful with your use of preservesinglequotes(). You're opening yourself up for a doozy of a SQL injection attack with the searchparam variable which isn't being sanitized. On to your question, if I follow what you are doing (I'm a little iffy on how jQuery works), I don't think you want the ?wsdl on the end of your web service URL. What you are telling CF with that is you expect an XML SOAP packet back with the json return string encoded inside of it. jQuery is expecting JUST the JSON returned from a specific method. View the url of your web service in a browser window and then VIEW SOURCE. The SOAP is there, you're just probably not seeing it. If you are going to access your web service this way you need to do it something like this: /ws/emp.cfc?method=getEmpInfo&searchparam=myvalue I know you are using jQuery and all, but the cfajaxproxy tag makes what you are doing simpler because it does all that stuff for you. Also, if you want your web service cfc to be reusable in instances where JSON is not the desired return type I believe you can use the &returnformat=json in the URL instead of serializing it int he CFC. ~Brad Original Message ---- Subject: Return JSON from a CFC From: "Joe" Date: Mon, January 05, 2009 1:42 pm To: cf-talk All, I recently created a small CFC returning query results in JSON format. The querying works, the regular CF page is able to call the CFC as a WSDL page properly passing params, and I am getting back JSON-like content. However I have been unable to parse the JSON content like an array within jQuery. I put the JSON variable inside an alert function in the CF page and I got a JSON-like string. I then replaced the web service URL in my CF page with the one from the following page: http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback When I reloaded the same CF page I got "[object Object]" and I was able to parse the results from that web service. So it seems like I'm missing something in my CFC that turns my JSON content into an object. I hope it's something obvious... ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317417 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Return JSON from a CFC
All, I recently created a small CFC returning query results in JSON format. The querying works, the regular CF page is able to call the CFC as a WSDL page properly passing params, and I am getting back JSON-like content. However I have been unable to parse the JSON content like an array within jQuery. I put the JSON variable inside an alert function in the CF page and I got a JSON-like string. I then replaced the web service URL in my CF page with the one from the following page: http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback When I reloaded the same CF page I got "[object Object]" and I was able to parse the results from that web service. So it seems like I'm missing something in my CFC that turns my JSON content into an object. I hope it's something obvious... My code is as follows: == Component: strQuery = "SELECT empname, oprid , str(emplid) as emplid FROM cae_alionOrgByUser where 1=1"; // "structKeyExists" is needed to use REFind if ( (structKeyExists(arguments,"searchparam") eq "Yes") AND (searchparam neq "") ) { if (REFind("[A-Za-z\.]+", searchparam) gt 0) { strQuery = strQuery & " and oprid like '%#searchparam#%'"; } if (REFind("\d+", searchparam) gt 0) { strQuery = strQuery & " and emplid like '%#searchparam#%'"; } } strQuery = strQuery & " ORDER BY empname"; #preservesinglequotes(strQuery)# == CF page: JavaScript var wsURL = '/ws/emp.cfc?wsdl'; // var wsURL = 'http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any &format=json&jsoncallback=?'; $.getJSON(wsURL, { method: 'getEmpInfo', searchParam: '101' }, function(jsondata) { alert(jsondata); alert(jsondata.DATA); // alert(jsondata.title); // $.each(jsondata.items, function(i,item){ // alert(item); // }); } ); == tia, - Joe ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317412 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Coldfusion 8 Unable to invoke CFC always added to error message
Since switching to ColdFusion 8, I noticed some weird issues with the returned error messages from the CFC. Let's say I call my login function from my Flex app, and the username and password are incorrect. The ColdFusion code would throw the following error: When I trace the returned fault event in the client (event.fault.faultString), I get the following message: "Unable to invoke CFC - You have entered an invalid username or password." Notice the additional "Unable to invoke CFC - " part to the message. For some reason it seems to be added to the message I returned. This was not an issue in ColdFusion 7, and it would be a pain in the ass to go through my Flex app and strip out that wherever an error is returned. In ColdFusion, I have tried throwing the error this way: It still had the same issue. Any ideas? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:316557 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Error invoking CFC
For the moment, it seems caching that query helped. I'm not getting any errors. I wish I'd seen that earlier. Thanks for your help G.. -Jeff > >Add cfdebug to your URL parameter and it will pop up the AJAX > debugger. > > > >On Thu, Nov 20, 2008 at 5:51 PM, Jeff F <[EMAIL PROTECTED]> > wrote: > > > >> > > Logs don't help. They just point to that getmodels.cfc. > > I'm wondering if my cfc is at fault. It's querying a rather large > table. Possibly taking too long?? I'm going to add > CachedWithin="#CreateTimeSpan(1,0,0,0)#" to see if that helps. > > > > > > SELECT distinct model > FROM #THIS.table# > WHERE approved = CFSQLType = "CF_SQL_VARCHAR"> > ORDER BY model > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:315744 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Error invoking CFC
>Add cfdebug to your URL parameter and it will pop up the AJAX debugger. > >On Thu, Nov 20, 2008 at 5:51 PM, Jeff F <[EMAIL PROTECTED]> wrote: > >> Logs don't help. They just point to that getmodels.cfc. I'm wondering if my cfc is at fault. It's querying a rather large table. Possibly taking too long?? I'm going to add CachedWithin="#CreateTimeSpan(1,0,0,0)#" to see if that helps. SELECT distinct model FROM #THIS.table# WHERE approved = ORDER BY model ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:315743 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Error invoking CFC
Add cfdebug to your URL parameter and it will pop up the AJAX debugger. On Thu, Nov 20, 2008 at 5:51 PM, Jeff F <[EMAIL PROTECTED]> wrote: > >Is that it for the error? Any other details to go by? Did you check the > log > >file to see if there were any other details? > > The complete error is: > > "Error invoking CFC /model/getfitmentdata.cfc : Internal Server Error > [Enable debugging by adding 'cfdebug' to your URL parameters to see more > information]" > > Not much more help. > > I'll check the logs now. > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:315741 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Error invoking CFC
>Is that it for the error? Any other details to go by? Did you check the log >file to see if there were any other details? The complete error is: "Error invoking CFC /model/getfitmentdata.cfc : Internal Server Error [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]" Not much more help. I'll check the logs now. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:315740 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Error invoking CFC
Is that it for the error? Any other details to go by? Did you check the log file to see if there were any other details? G On Thu, Nov 20, 2008 at 5:15 PM, Jeff F <[EMAIL PROTECTED]> wrote: > For the life of me I can't figure out how to stop this error. > Sometimes when I call the page that invokes the CFC, It gives an > error: "Error invoking CFC ". It does not happen all time though. 8 > times out of ten it will load fine, then throw the error every once an > a while. > > It's almost like the framework is sleeping, and can't load things > quick enough before an error is thrown. > > I'm on a VPS. Any suggestions appreciated, I'm out of ideas. > > -Jeff > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:315739 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Error invoking CFC
More on this... Ok, more on this. I'm using CFSelect and binding to this cfc. Is there any odd issues with binding in a CFC?? jeff >For the life of me I can't figure out how to stop this error. >Sometimes when I call the page that invokes the CFC, It gives an >error: "Error invoking CFC ". It does not happen all time though. 8 >times out of ten it will load fine, then throw the error every once an >a while. > >It's almost like the framework is sleeping, and can't load things >quick enough before an error is thrown. > >I'm on a VPS. Any suggestions appreciated, I'm out of ideas. > >-Jeff ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:315738 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Error invoking CFC
For the life of me I can't figure out how to stop this error. Sometimes when I call the page that invokes the CFC, It gives an error: "Error invoking CFC ". It does not happen all time though. 8 times out of ten it will load fine, then throw the error every once an a while. It's almost like the framework is sleeping, and can't load things quick enough before an error is thrown. I'm on a VPS. Any suggestions appreciated, I'm out of ideas. -Jeff ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:315737 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
Thanks for the info, Dominic! Rick Dominic Watson wrote: > If you ever build a facebook application with ColdFusion you will run > into this exact same problem. Basically, Facebook send a post request > to your server which always breaks because there are two important > fields called FB_SIG_TIME and FB_SIG. ColdFusion tries to validate > FB_SIG as a time field, which it is not, and so a 500 is thrown. > Classic eh. > > I believe that Mr Camden is using the Facebook case to suggest to the > CF devs that they make this feature optional through the > Administrator; I may be wrong though. > > Dominic > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314759 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
If you ever build a facebook application with ColdFusion you will run into this exact same problem. Basically, Facebook send a post request to your server which always breaks because there are two important fields called FB_SIG_TIME and FB_SIG. ColdFusion tries to validate FB_SIG as a time field, which it is not, and so a 500 is thrown. Classic eh. I believe that Mr Camden is using the Facebook case to suggest to the CF devs that they make this feature optional through the Administrator; I may be wrong though. Dominic ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314758 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
Thanks for the info, Dave. I guess I've just not used the right (or wrong) variable names to trigger that auto-validation. I recall seeing it now...just never made use of it, preferring to write my own. But I'll look into it. It may make validation easier for many types of data. Rick Dave Watts wrote: >>> I don't think that's exactly it. There are a bunch of automatic >>> validation suffixes, like "_date" and "_time" which trigger built-in >>> CF form validation. Typically, they're used by adding hidden form >>> fields to your form, and naming those fields using the names of the >>> fields to be validated and the appropriate validation suffix: >>> >>> >>> >>> >> But I'm using , not . Would that cause CF validation >> to be triggered, as well? >> > > Yes. This built-in validation functionality predates the CFFORM tag. > > Dave Watts, CTO, Fig Leaf Software > http://www.figleaf.com/ > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314757 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC and Form Variables Question
>> I don't think that's exactly it. There are a bunch of automatic >> validation suffixes, like "_date" and "_time" which trigger built-in >> CF form validation. Typically, they're used by adding hidden form >> fields to your form, and naming those fields using the names of the >> fields to be validated and the appropriate validation suffix: >> >> >> > > But I'm using , not . Would that cause CF validation > to be triggered, as well? Yes. This built-in validation functionality predates the CFFORM tag. 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! ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314756 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
But I'm using , not . Would that cause CF validation to be triggered, as well? Rick Dave Watts wrote: >> It seems that CF didn't like having variables named with two underscores >> in them. >> >> I had these four field names that were causing problems. >> >> - home_phone >> - home_phone_time >> - work_phone >> - work_phone_time >> >> Once I changed them to... >> >> - home_phone >> - home_calltime >> - work_phone >> - work_calltime >> >> everything began to run as expected. >> > > I don't think that's exactly it. There are a bunch of automatic > validation suffixes, like "_date" and "_time" which trigger built-in > CF form validation. Typically, they're used by adding hidden form > fields to your form, and naming those fields using the names of the > fields to be validated and the appropriate validation suffix: > > > > > 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! > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314755 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC and Form Variables Question
> It seems that CF didn't like having variables named with two underscores > in them. > > I had these four field names that were causing problems. > > - home_phone > - home_phone_time > - work_phone > - work_phone_time > > Once I changed them to... > > - home_phone > - home_calltime > - work_phone > - work_calltime > > everything began to run as expected. I don't think that's exactly it. There are a bunch of automatic validation suffixes, like "_date" and "_time" which trigger built-in CF form validation. Typically, they're used by adding hidden form fields to your form, and naming those fields using the names of the fields to be validated and the appropriate validation suffix: 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! ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314753 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
Well... I finally figured out what the problem was. It seems that CF didn't like having variables named with two underscores in them. I had these four field names that were causing problems. - home_phone - home_phone_time - work_phone - work_phone_time Once I changed them to... - home_phone - home_calltime - work_phone - work_calltime everything began to run as expected. Man, what a waste of time that was! Thanks for everyone's suggestions! Rick William Seiter wrote: > There has to be some other process that is running to validate data in your > fields. If you change the error messages and then force the error to be > shown, are you able to see those errors when you run the page? > > Change the error message of: 'Please enter your name.' to 'Please enter your > full name.' > Submit the form with the name area 'blank'. > Check to see if you can view the new message or the old message (or neither > one). > > Also, check to make sure that the error reporting you are experiencing isn't > from a javascript being called on those other fields. > > William > > -- > William Seiter > IT Web Developer / Consultant > > Is your income limited by the red tape and paperwork? Let SoftEx BackOffice > help you. They know how to take care of the 'busy work' of your contracts > and let you focus on the 'WOW' factor. > http://www.softexconsulting.com/backoffice.cfm > ::-Original Message- > ::From: Rick Faircloth [mailto:[EMAIL PROTECTED] > ::Sent: Sunday, November 02, 2008 7:18 AM > ::To: cf-talk > ::Subject: Re: CFC and Form Variables Question > :: > ::Hi, Azadi, and thanks for the feedback. > :: > ::I tried every combination I could think of...modifying variables in > ::the form_validation.cfc as well as the email_processing.cfc, but nothing > ::changed. > :: > ::The fields throwing the errors aren't even involved in the validation > ::in form_validation.cfc... > :: > ::I tried before ::structNew()> > ::if that's what you meant, but that didn't help. > :: > ::I just can't figure out what is performing the validation and rejecting my > ::field data. Do CFC's perform some kind of validation inherently? > :: > ::Again, if I leave data out of the fields causing the problem, the form > ::processes normally. > :: > ::Rick > :: > :: > :: > ::Azadi Saryev wrote: > ::> - you are not VAR'ing your cfc > ::variables, so some var leaking/confusion may be going on... > ::> > ::> Azadi Saryev > ::> Sabai-dee.com > ::> http://www.sabai-dee.com/ > ::> > ::> > ::> > ::> Rick Faircloth wrote: > ::> > ::>> Yeah, I know... I was trying not to get to deep into the code since it > ::>> involves so many parts, but here' s shortened version: > ::>> > ::>> > ::>> > ::> > ::> > :: > :: > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314751 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: CFC and Form Variables Question
There has to be some other process that is running to validate data in your fields. If you change the error messages and then force the error to be shown, are you able to see those errors when you run the page? Change the error message of: 'Please enter your name.' to 'Please enter your full name.' Submit the form with the name area 'blank'. Check to see if you can view the new message or the old message (or neither one). Also, check to make sure that the error reporting you are experiencing isn't from a javascript being called on those other fields. William -- William Seiter IT Web Developer / Consultant Is your income limited by the red tape and paperwork? Let SoftEx BackOffice help you. They know how to take care of the 'busy work' of your contracts and let you focus on the 'WOW' factor. http://www.softexconsulting.com/backoffice.cfm ::-Original Message- ::From: Rick Faircloth [mailto:[EMAIL PROTECTED] ::Sent: Sunday, November 02, 2008 7:18 AM ::To: cf-talk ::Subject: Re: CFC and Form Variables Question :: ::Hi, Azadi, and thanks for the feedback. :: ::I tried every combination I could think of...modifying variables in ::the form_validation.cfc as well as the email_processing.cfc, but nothing ::changed. :: ::The fields throwing the errors aren't even involved in the validation ::in form_validation.cfc... :: ::I tried before ::if that's what you meant, but that didn't help. :: ::I just can't figure out what is performing the validation and rejecting my ::field data. Do CFC's perform some kind of validation inherently? :: ::Again, if I leave data out of the fields causing the problem, the form ::processes normally. :: ::Rick :: :: :: ::Azadi Saryev wrote: ::> - you are not VAR'ing your cfc ::variables, so some var leaking/confusion may be going on... ::> ::> Azadi Saryev ::> Sabai-dee.com ::> http://www.sabai-dee.com/ ::> ::> ::> ::> Rick Faircloth wrote: ::> ::>> Yeah, I know... I was trying not to get to deep into the code since it ::>> involves so many parts, but here' s shortened version: ::>> ::>> ::>> ::> ::> :: :: ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314749 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
Hi, Azadi, and thanks for the feedback. I tried every combination I could think of...modifying variables in the form_validation.cfc as well as the email_processing.cfc, but nothing changed. The fields throwing the errors aren't even involved in the validation in form_validation.cfc... I tried before if that's what you meant, but that didn't help. I just can't figure out what is performing the validation and rejecting my field data. Do CFC's perform some kind of validation inherently? Again, if I leave data out of the fields causing the problem, the form processes normally. Rick Azadi Saryev wrote: > - you are not VAR'ing your cfc variables, > so some var leaking/confusion may be going on... > > Azadi Saryev > Sabai-dee.com > http://www.sabai-dee.com/ > > > > Rick Faircloth wrote: > >> Yeah, I know... I was trying not to get to deep into the code since it >> involves so many parts, but here' s shortened version: >> >> >> > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314748 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC and Form Variables Question
- you are not VAR'ing your cfc variables, so some var leaking/confusion may be going on... Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ Rick Faircloth wrote: > Yeah, I know... I was trying not to get to deep into the code since it > involves so many parts, but here' s shortened version: > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314747 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
Yeah, I know... I was trying not to get to deep into the code since it involves so many parts, but here' s shortened version: - cma.cfm (calling page) - When the page is submitted back to itself, this code kicks in: - form_validation.cfc - - email_processing.cfc - The following Comparative Marketing Request was sent from the FortStewart.com website: Date: #dateformat(now(), 'mmm d, ')# Time: #timeformat(now(), 'h:mm tt')# Name: #arguments.name# Email Address: #arguments.email# Home Phone: #arguments.home_phone# Best time to call at home: #arguments.home_phone_time# (etc) The cfc's work fine when the home_phone, home_phone_time, work_phone, and work_phone_time fields are left empty. ??? Thanks, Rick Adrian Lynch wrote: > Kinda hard to tell you what's wrong without some code. > > Adrian > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314746 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: CFC and Form Variables Question
Kinda hard to tell you what's wrong without some code. Adrian -Original Message- From: Rick Faircloth Sent: 02 November 2008 12:36 To: cf-talk Subject: Re: CFC and Form Variables Question Do CFC's have some sort of internal validation routine associated with them? I'm running my form data through the validation CFC and all checks out then returns to the calling page and the email_processing CFC is called and I get data formatting errors. ??? For example, I have a text input for best time to call at home and I'm entering the time as 10:00 am, which I've always done before, but now, I get: "Form entries are incomplete or invalid" 10:00 am Go back and correct the problem. This is a regular text field with no validation from me, set to accept whatever the user types in, even "Before 9am.". When I remove 10:00 am to get past the error, I get an error for the home phone number, 913-878-3343, which again is a regular text field, with no validation by me. "Form entries are incomplete or invalid." "The value entered for the HOME_PHONE field ('913-878-3343') is not correctly formatted." What's doing the validation? The CFC? That's not what I want... Rick Adrian Lynch wrote: > "My conclusion was that CFCs treated as function libraries incurred > unnecessary overhead while offering no additional benefit over a pre-CFC > function library." > > Because you were creating the object each time? You could have cached it. > > Adrian > Building a database of ColdFusion errors at http://cferror.org/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314745 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
Do CFC's have some sort of internal validation routine associated with them? I'm running my form data through the validation CFC and all checks out then returns to the calling page and the email_processing CFC is called and I get data formatting errors. ??? For example, I have a text input for best time to call at home and I'm entering the time as 10:00 am, which I've always done before, but now, I get: "Form entries are incomplete or invalid" 10:00 am Go back and correct the problem. This is a regular text field with no validation from me, set to accept whatever the user types in, even "Before 9am.". When I remove 10:00 am to get past the error, I get an error for the home phone number, 913-878-3343, which again is a regular text field, with no validation by me. "Form entries are incomplete or invalid." "The value entered for the HOME_PHONE field ('913-878-3343') is not correctly formatted." What's doing the validation? The CFC? That's not what I want... Rick Adrian Lynch wrote: > "My conclusion was that CFCs treated as function libraries incurred > unnecessary overhead while offering no additional benefit over a pre-CFC > function library." > > Because you were creating the object each time? You could have cached it. > > Adrian > Building a database of ColdFusion errors at http://cferror.org/ > > -Original Message- > From: Mike Chabot > Sent: 02 November 2008 03:01 > To: cf-talk > Subject: Re: CFC and Form Variables Question > > > Regarding this.validate, I'm writing abstractly to refer to validating > an object's data within the object as opposed to sending it out to a > separate validation object. You won't find this in any manual. > > Back when CFCs first came out I extensively researched how best to > handle function libraries since I was creating a very high profile, > high traffic, mission critical Web application. I was trying to make > use of CFCs extensively because I saw that as the direction CF was > headed and it was the hot new feature. My conclusion was that CFCs > treated as function libraries incurred unnecessary overhead while > offering no additional benefit over a pre-CFC function library. With > CF8 things are different in that CFCs in CF8 are much faster, plus > they play nice with technologies such as AJAX and Flex. > > Going back to your original question, you can pass the form structure > into a CFC function if you want to. It still seems strange to me, but > many decisions in CF come down to personal preference. > > -Mike Chabot > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314744 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: CFC and Form Variables Question
"My conclusion was that CFCs treated as function libraries incurred unnecessary overhead while offering no additional benefit over a pre-CFC function library." Because you were creating the object each time? You could have cached it. Adrian Building a database of ColdFusion errors at http://cferror.org/ -Original Message- From: Mike Chabot Sent: 02 November 2008 03:01 To: cf-talk Subject: Re: CFC and Form Variables Question Regarding this.validate, I'm writing abstractly to refer to validating an object's data within the object as opposed to sending it out to a separate validation object. You won't find this in any manual. Back when CFCs first came out I extensively researched how best to handle function libraries since I was creating a very high profile, high traffic, mission critical Web application. I was trying to make use of CFCs extensively because I saw that as the direction CF was headed and it was the hot new feature. My conclusion was that CFCs treated as function libraries incurred unnecessary overhead while offering no additional benefit over a pre-CFC function library. With CF8 things are different in that CFCs in CF8 are much faster, plus they play nice with technologies such as AJAX and Flex. Going back to your original question, you can pass the form structure into a CFC function if you want to. It still seems strange to me, but many decisions in CF come down to personal preference. -Mike Chabot ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314743 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
I think I see what you're saying. I'll have to give it some thought and work on implementation. Thanks. Rick Mike Chabot wrote: > Regarding this.validate, I'm writing abstractly to refer to validating > an object's data within the object as opposed to sending it out to a > separate validation object. You won't find this in any manual. > > Back when CFCs first came out I extensively researched how best to > handle function libraries since I was creating a very high profile, > high traffic, mission critical Web application. I was trying to make > use of CFCs extensively because I saw that as the direction CF was > headed and it was the hot new feature. My conclusion was that CFCs > treated as function libraries incurred unnecessary overhead while > offering no additional benefit over a pre-CFC function library. With > CF8 things are different in that CFCs in CF8 are much faster, plus > they play nice with technologies such as AJAX and Flex. > > Going back to your original question, you can pass the form structure > into a CFC function if you want to. It still seems strange to me, but > many decisions in CF come down to personal preference. > > -Mike Chabot > > On Sat, Nov 1, 2008 at 5:49 PM, Rick Faircloth <[EMAIL PROTECTED]> wrote: > >> You're right, Mike... >> >> I'm just using the CFC as more of a function library, not so much from >> an OOP standpoint. (I only learned to use CFC's effectively in the last >> week or so :o) >> >> I'll have to dig into the "this.validate()" method a little more to >> understand it. >> I did see it discussed in the livedocs, but figured that would slow >> things down >> a little too much for now. >> >> Once I get CFC's down, I'll work on the OOP style more. >> >> Don't want overload my little rowboat with too much of a motor! >> I still need a trolling motor, not a twin-engine! :o) >> >> Rick >> >> Mike Chabot wrote: >> >>> Rick, >>> Basic form validation is along the lines of "was the first name >>> entered" and "is the length of the first name GT 0" are often specific >>> to a single form in the site and don't benefit from being abstracted. >>> >From an OOP standpoint, the object can be the page, the form, or a >>> form field. A validation function is something that could be part of >>> one of those objects. For example, if you consider your form to be an >>> object, then a this.validate() method would be part of the form object >>> and you wouldn't need to pass the form data en-mass to another CFC >>> since you are staying within the same object. The question of how you >>> pass the form scope to another CFC goes away and the problem is >>> simplified. >>> >>> I would guess that what you have is more of a function library and >>> that you are putting them into a CFC because they are similar code, >>> not because you are practicing OOP. You can certainly do this if you >>> think this makes your site easier to maintain. I'm making assumptions >>> about what your validation code is doing and have no way of knowing >>> what is best for your site, but hopefully I explained my "taking a >>> step back" comment on whether it makes more sense to call >>> Object2.validate(Object1.data) instead of calling >>> Object1.validate(this) since taking the latter approach might nullify >>> your question. >>> >>> -Mike Chabot >>> > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314742 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC and Form Variables Question
Regarding this.validate, I'm writing abstractly to refer to validating an object's data within the object as opposed to sending it out to a separate validation object. You won't find this in any manual. Back when CFCs first came out I extensively researched how best to handle function libraries since I was creating a very high profile, high traffic, mission critical Web application. I was trying to make use of CFCs extensively because I saw that as the direction CF was headed and it was the hot new feature. My conclusion was that CFCs treated as function libraries incurred unnecessary overhead while offering no additional benefit over a pre-CFC function library. With CF8 things are different in that CFCs in CF8 are much faster, plus they play nice with technologies such as AJAX and Flex. Going back to your original question, you can pass the form structure into a CFC function if you want to. It still seems strange to me, but many decisions in CF come down to personal preference. -Mike Chabot On Sat, Nov 1, 2008 at 5:49 PM, Rick Faircloth <[EMAIL PROTECTED]> wrote: > You're right, Mike... > > I'm just using the CFC as more of a function library, not so much from > an OOP standpoint. (I only learned to use CFC's effectively in the last > week or so :o) > > I'll have to dig into the "this.validate()" method a little more to > understand it. > I did see it discussed in the livedocs, but figured that would slow > things down > a little too much for now. > > Once I get CFC's down, I'll work on the OOP style more. > > Don't want overload my little rowboat with too much of a motor! > I still need a trolling motor, not a twin-engine! :o) > > Rick > > Mike Chabot wrote: >> Rick, >> Basic form validation is along the lines of "was the first name >> entered" and "is the length of the first name GT 0" are often specific >> to a single form in the site and don't benefit from being abstracted. >> >From an OOP standpoint, the object can be the page, the form, or a >> form field. A validation function is something that could be part of >> one of those objects. For example, if you consider your form to be an >> object, then a this.validate() method would be part of the form object >> and you wouldn't need to pass the form data en-mass to another CFC >> since you are staying within the same object. The question of how you >> pass the form scope to another CFC goes away and the problem is >> simplified. >> >> I would guess that what you have is more of a function library and >> that you are putting them into a CFC because they are similar code, >> not because you are practicing OOP. You can certainly do this if you >> think this makes your site easier to maintain. I'm making assumptions >> about what your validation code is doing and have no way of knowing >> what is best for your site, but hopefully I explained my "taking a >> step back" comment on whether it makes more sense to call >> Object2.validate(Object1.data) instead of calling >> Object1.validate(this) since taking the latter approach might nullify >> your question. >> >> -Mike Chabot ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314741 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC and Form Variables Question
You're right, Mike... I'm just using the CFC as more of a function library, not so much from an OOP standpoint. (I only learned to use CFC's effectively in the last week or so :o) I'll have to dig into the "this.validate()" method a little more to understand it. I did see it discussed in the livedocs, but figured that would slow things down a little too much for now. Once I get CFC's down, I'll work on the OOP style more. Don't want overload my little rowboat with too much of a motor! I still need a trolling motor, not a twin-engine! :o) Rick Mike Chabot wrote: > Rick, > Basic form validation is along the lines of "was the first name > entered" and "is the length of the first name GT 0" are often specific > to a single form in the site and don't benefit from being abstracted. > >From an OOP standpoint, the object can be the page, the form, or a > form field. A validation function is something that could be part of > one of those objects. For example, if you consider your form to be an > object, then a this.validate() method would be part of the form object > and you wouldn't need to pass the form data en-mass to another CFC > since you are staying within the same object. The question of how you > pass the form scope to another CFC goes away and the problem is > simplified. > > I would guess that what you have is more of a function library and > that you are putting them into a CFC because they are similar code, > not because you are practicing OOP. You can certainly do this if you > think this makes your site easier to maintain. I'm making assumptions > about what your validation code is doing and have no way of knowing > what is best for your site, but hopefully I explained my "taking a > step back" comment on whether it makes more sense to call > Object2.validate(Object1.data) instead of calling > Object1.validate(this) since taking the latter approach might nullify > your question. > > -Mike Chabot > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314732 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
Rick, Basic form validation is along the lines of "was the first name entered" and "is the length of the first name GT 0" are often specific to a single form in the site and don't benefit from being abstracted. >From an OOP standpoint, the object can be the page, the form, or a form field. A validation function is something that could be part of one of those objects. For example, if you consider your form to be an object, then a this.validate() method would be part of the form object and you wouldn't need to pass the form data en-mass to another CFC since you are staying within the same object. The question of how you pass the form scope to another CFC goes away and the problem is simplified. I would guess that what you have is more of a function library and that you are putting them into a CFC because they are similar code, not because you are practicing OOP. You can certainly do this if you think this makes your site easier to maintain. I'm making assumptions about what your validation code is doing and have no way of knowing what is best for your site, but hopefully I explained my "taking a step back" comment on whether it makes more sense to call Object2.validate(Object1.data) instead of calling Object1.validate(this) since taking the latter approach might nullify your question. -Mike Chabot ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314729 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC and Form Variables Question
> /> > > > > > That's exactly the approach I was taking when I started this thread. I was just unsure of whether each independent CFC called would have access to the form variables. Here's what my code looks like (I coded these calls when my question about access to form variables in the two different CFC's occurred to me...) Dominic Watson wrote: >> I'm considering taking the approach of making the appropriate email >> routines that >> follow validation routines, "children" (I think that's the term) of the >> validation routines >> so there's only one call from the calling page and then the data flows >> through the >> process of validation and emailing, then returns to the calling page >> only once. >> > > I think best design would have both your validation() and email() > methods entirely ignorant of each other. They do what they say they do > - one validates data, the other sends an email. The calling template > acts as the 'controller' and coordinates the calls. This gives you the > most flexibility and reusability. > > Let's say that the validation method returns a structure of error > messages related to form fields (the struct keys being the form > element names). If this was called from within the sendEmail() method, > you might be limited with what you could do in terms of handling those > errors, or, if not limited you'd have to scratch your head a bit to > figure where the handling should go and how it should all be handled. > Seperate the logic out and you have: > > > > > > > > > Even if you will have a much simpler error system, ie. true or false > to validation, seperating the logic to this extent gives you the > flexibility to change the error handling without having to change the > rest of the code. > > While making less 'calls' from your calling page may seem like a noble > cause, you should be weary of sacrificing separation which is what you > would being doing here. > > HTH > > Dominic > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314727 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC and Form Variables Question
>I'm considering taking the approach of making the appropriate email >routines that >follow validation routines, "children" (I think that's the term) of the >validation routines >so there's only one call from the calling page and then the data flows >through the >process of validation and emailing, then returns to the calling page >only once. I think best design would have both your validation() and email() methods entirely ignorant of each other. They do what they say they do - one validates data, the other sends an email. The calling template acts as the 'controller' and coordinates the calls. This gives you the most flexibility and reusability. Let's say that the validation method returns a structure of error messages related to form fields (the struct keys being the form element names). If this was called from within the sendEmail() method, you might be limited with what you could do in terms of handling those errors, or, if not limited you'd have to scratch your head a bit to figure where the handling should go and how it should all be handled. Seperate the logic out and you have: Even if you will have a much simpler error system, ie. true or false to validation, seperating the logic to this extent gives you the flexibility to change the error handling without having to change the rest of the code. While making less 'calls' from your calling page may seem like a noble cause, you should be weary of sacrificing separation which is what you would being doing here. HTH Dominic ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314726 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
> To more specifically answer your question, avoid the variables scope > inside of a CFC if you can. You can use that, but it is generally > considered bad design and it can lead to problems that are hard to > troubleshoot. The variables scope should not be used for what Rick was suggesting but 'avoid[ing] the variables scope inside of a CFC..' in general is not correct. What *is* considered bad design however, is mixing logic with display code as you suggest ('Why not just put the validation code right in the page...'). Rick is simply putting the data validation into a method within a cfc (not a form_validation.cfc), and seperating his logic; nothing awkward about it. Dominic ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314725 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC and Form Variables Question
> why are you using a form validation CFC? No specific reason for using a CFC, except that I can put all my form validation routines into a single CFC easily enough. My normal practice is to have a page submit back to itself (and even with a CFC or two involved, I still do that), but I've been trying to follow the basic reason it seems for using CFC's at all, which seems to be separating logic from presentation, the same way I'm now using stylesheets more extensively. I can certainly use a cfinclude, but then, unless I use some cfswitch to differentiate routines, I'll have to have a lot of cfincludes as opposed to just one CFC with various methods. Why does having a "form_validation.cfc" seem awkward? I'm considering taking the approach of making the appropriate email routines that follow validation routines, "children" (I think that's the term) of the validation routines so there's only one call from the calling page and then the data flows through the process of validation and emailing, then returns to the calling page only once. Thoughts on that? As far as using the variables scope in cfc's, I typically don't if the data in being used on in that specific cfc. I just use the arguments scope... less typing. More thoughts and perspectives? Thanks, Rick Mike Chabot wrote: > Taking a step back, why are you using a form validation CFC? Your goal > is that you want to validate a form then send an email. So the simple > way to do this is to post the form to itself, then at the top of the > page detect whether the page is posted to itself, run it through some > validation checks and then send the email. Why not just put the > validation code right in the page or in a cfinclude, or in a custom > tag, or in a UDF library. The concept of having a > "form_validation.cfc" seems awkward. Is there a specific reason that > you are doing this? > > To more specifically answer your question, avoid the variables scope > inside of a CFC if you can. You can use that, but it is generally > considered bad design and it can lead to problems that are hard to > troubleshoot. > > -Mike Chabot > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314724 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC and Form Variables Question
> Should read: As for 'sharing' variables between *methods* I picked up on that one. :o) Thanks for the feedback. I'll give it some thought and see what happens. Rick Dominic Watson wrote: > Sorry, hungover > > >> >> >> >> >> >> > > Should read: > > > > > > > > And: > > >> As for 'sharing' variables between arguments within a single cfc... >> > > Should read: As for 'sharing' variables between *methods* within a > single cfc... > > > ! Dominic > > 2008/11/1 Dominic Watson <[EMAIL PROTECTED]>: > >> Personally, I'd prefer the first approach. The validation method >> should only be concerned with validating the form; it should not know >> what to do if the form validates. However, it *would* make sense to do >> it the other way around; ie. call the email method, which first calls >> the validation method and acts accordingly. >> >> As for 'sharing' variables between arguments within a single cfc, I'd >> say you would always want to use the arguments scope for passing the >> data around. Both these choices make for maximising the reusability of >> your code. >> >> Consider: >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > subject="#arguments.bar#" ...> >> Hello world. >> >> >> >> >> >> >> >> myComponent.sendEmail(argumentCollection = form); >> >> >> One final thing I would say is that, personally, I prefer not to use >> argumentCollection if it is practical not to do so. If you know what >> variables need to be passed from the form scope, write them out >> explicitly; it will help with readability, ie. >> >> myComponent.sendEmail( form.foo, form.bar ); >> >> I find argumentCollection really useful when needing to send in a >> dynamic amount of arguments when there are lots of optional arguments >> for a function. A good example would be in a reporting function that >> takes several filters. So: >> >> filters = structNew(); >> if(form.filterX NEQ 'any') >>filters.filterX = form.filterX; >> if(form.filterY NEQ 0) >>filters.filterY = form.filterY; >> >> myComponent.getReport( argumentCollection = filters ) >> >> HTH >> >> Dominic >> >> 2008/11/1 Rick Faircloth <[EMAIL PROTECTED]>: >> >>> Hi, Dominic and thanks for the reply... >>> >>> The second option sounds more like what I'm wanting to do. >>> >>> And while reading your response, it occurred to me that if I >>> send the form data to a cfc for validation, and it validates, >>> I could just go straight to another method (how about to another cfc?) >>> for the email processing >>> without going back to the orginal form page and then to the >>> email processing cfc. (make sense?) >>> >>> So, I would go from form page to validation method, and if all validates, >>> straight to the email method to send emails. >>> >>> And from your description below, I would just refer to the >>> arguments.variables >>> in the second method as in the first? No, I guess I couldn't use the >>> "arguments" scope >>> and share variables between methods...I'd need to put the data into the >>> "variables" scope >>> to share between methods. Right? >>> >>> And, if that's so, I guess each form variable has to be established in >>> the first validation >>> method by translating each piece of data in to the variable scope with >>> in order to share those >>> variables within a CFC. >>> >>> Am I correct? >>> >>> Thanks for the feedback. >>> >>> Rick >>> >>> Dominic Watson wrote: >>> >>>> Something like this? >>>> >>>> >>>> >>> anotherObject.doSomethingWithF
Re: CFC and Form Variables Question
Taking a step back, why are you using a form validation CFC? Your goal is that you want to validate a form then send an email. So the simple way to do this is to post the form to itself, then at the top of the page detect whether the page is posted to itself, run it through some validation checks and then send the email. Why not just put the validation code right in the page or in a cfinclude, or in a custom tag, or in a UDF library. The concept of having a "form_validation.cfc" seems awkward. Is there a specific reason that you are doing this? To more specifically answer your question, avoid the variables scope inside of a CFC if you can. You can use that, but it is generally considered bad design and it can lead to problems that are hard to troubleshoot. -Mike Chabot On Sat, Nov 1, 2008 at 12:28 PM, Rick Faircloth <[EMAIL PROTECTED]> wrote: > Hi, Dominic and thanks for the reply... > > The second option sounds more like what I'm wanting to do. > > And while reading your response, it occurred to me that if I > send the form data to a cfc for validation, and it validates, > I could just go straight to another method (how about to another cfc?) > for the email processing > without going back to the orginal form page and then to the > email processing cfc. (make sense?) > > So, I would go from form page to validation method, and if all validates, > straight to the email method to send emails. > > And from your description below, I would just refer to the > arguments.variables > in the second method as in the first? No, I guess I couldn't use the > "arguments" scope > and share variables between methods...I'd need to put the data into the > "variables" scope > to share between methods. Right? > > And, if that's so, I guess each form variable has to be established in > the first validation > method by translating each piece of data in to the variable scope with > in order to share those > variables within a CFC. > > Am I correct? > > Thanks for the feedback. > > Rick > > Dominic Watson wrote: >> Something like this? >> >> >> > anotherObject.doSomethingWithForm(argumentCollection = form) /> >> >> Form did not validate >> >> >> Or, are you wanting to pass the form data to another cfc method from >> within the validation method? If so, something like this: >> >> >> >> >> >> >> ... >> someOtherObject.doSomethingWithFormData( argumentCollection = >> arguments ) ; >> ... >> >> >> >> Dominic >> >> 2008/11/1 Rick Faircloth <[EMAIL PROTECTED]>: >> >>> Hi, all... >>> >>> Can form variables be passed around between a calling page and >>> multiple cfc's? >>> >>> I have a form with data I want to validate, then generate an email with. >>> >>> I have the calling page with the form, which sends the form data via >>> argumentCollection, >>> to a form_validation.cfc. If the form data passes validation, then I >>> want to send the form >>> data to an email_processing.cfc for email generation. >>> >>> Would the form variables be available to the calling page and both cfc's >>> in this case? >>> Or do I need to create session variables or another type of variable to >>> pass the values >>> around? >>> >>> Thanks, >>> >>> Rick >>> >>> >>> >> >> > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314721 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC and Form Variables Question
Sorry, hungover > > > > > Should read: And: > As for 'sharing' variables between arguments within a single cfc... Should read: As for 'sharing' variables between *methods* within a single cfc... ! Dominic 2008/11/1 Dominic Watson <[EMAIL PROTECTED]>: > Personally, I'd prefer the first approach. The validation method > should only be concerned with validating the form; it should not know > what to do if the form validates. However, it *would* make sense to do > it the other way around; ie. call the email method, which first calls > the validation method and acts accordingly. > > As for 'sharing' variables between arguments within a single cfc, I'd > say you would always want to use the arguments scope for passing the > data around. Both these choices make for maximising the reusability of > your code. > > Consider: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >subject="#arguments.bar#" ...> > Hello world. > > > > > > > > myComponent.sendEmail(argumentCollection = form); > > > One final thing I would say is that, personally, I prefer not to use > argumentCollection if it is practical not to do so. If you know what > variables need to be passed from the form scope, write them out > explicitly; it will help with readability, ie. > > myComponent.sendEmail( form.foo, form.bar ); > > I find argumentCollection really useful when needing to send in a > dynamic amount of arguments when there are lots of optional arguments > for a function. A good example would be in a reporting function that > takes several filters. So: > > filters = structNew(); > if(form.filterX NEQ 'any') >filters.filterX = form.filterX; > if(form.filterY NEQ 0) >filters.filterY = form.filterY; > > myComponent.getReport( argumentCollection = filters ) > > HTH > > Dominic > > 2008/11/1 Rick Faircloth <[EMAIL PROTECTED]>: >> Hi, Dominic and thanks for the reply... >> >> The second option sounds more like what I'm wanting to do. >> >> And while reading your response, it occurred to me that if I >> send the form data to a cfc for validation, and it validates, >> I could just go straight to another method (how about to another cfc?) >> for the email processing >> without going back to the orginal form page and then to the >> email processing cfc. (make sense?) >> >> So, I would go from form page to validation method, and if all validates, >> straight to the email method to send emails. >> >> And from your description below, I would just refer to the >> arguments.variables >> in the second method as in the first? No, I guess I couldn't use the >> "arguments" scope >> and share variables between methods...I'd need to put the data into the >> "variables" scope >> to share between methods. Right? >> >> And, if that's so, I guess each form variable has to be established in >> the first validation >> method by translating each piece of data in to the variable scope with >> in order to share those >> variables within a CFC. >> >> Am I correct? >> >> Thanks for the feedback. >> >> Rick >> >> Dominic Watson wrote: >>> Something like this? >>> >>> >>> >> anotherObject.doSomethingWithForm(argumentCollection = form) /> >>> >>> Form did not validate >>> >>> >>> Or, are you wanting to pass the form data to another cfc method from >>> within the validation method? If so, something like this: >>> >>> >>> >>> >>> >>> >>> ... >>> someOtherObject.doSomethingWithFormData( argumentCollection = >>> arguments ) ; >>> ... >>> >>> >>> >>> Dominic >>> >>> 2008/11/1 Rick Faircloth <[EMAIL PROTECTED]>: >>> >>>> Hi, all... >>>> >>>> Can form variables be passed around between a calling page and >>>> multiple cfc's? >>>> >>>> I have a form with data
Re: CFC and Form Variables Question
Personally, I'd prefer the first approach. The validation method should only be concerned with validating the form; it should not know what to do if the form validates. However, it *would* make sense to do it the other way around; ie. call the email method, which first calls the validation method and acts accordingly. As for 'sharing' variables between arguments within a single cfc, I'd say you would always want to use the arguments scope for passing the data around. Both these choices make for maximising the reusability of your code. Consider: Hello world. myComponent.sendEmail(argumentCollection = form); One final thing I would say is that, personally, I prefer not to use argumentCollection if it is practical not to do so. If you know what variables need to be passed from the form scope, write them out explicitly; it will help with readability, ie. myComponent.sendEmail( form.foo, form.bar ); I find argumentCollection really useful when needing to send in a dynamic amount of arguments when there are lots of optional arguments for a function. A good example would be in a reporting function that takes several filters. So: filters = structNew(); if(form.filterX NEQ 'any') filters.filterX = form.filterX; if(form.filterY NEQ 0) filters.filterY = form.filterY; myComponent.getReport( argumentCollection = filters ) HTH Dominic 2008/11/1 Rick Faircloth <[EMAIL PROTECTED]>: > Hi, Dominic and thanks for the reply... > > The second option sounds more like what I'm wanting to do. > > And while reading your response, it occurred to me that if I > send the form data to a cfc for validation, and it validates, > I could just go straight to another method (how about to another cfc?) > for the email processing > without going back to the orginal form page and then to the > email processing cfc. (make sense?) > > So, I would go from form page to validation method, and if all validates, > straight to the email method to send emails. > > And from your description below, I would just refer to the > arguments.variables > in the second method as in the first? No, I guess I couldn't use the > "arguments" scope > and share variables between methods...I'd need to put the data into the > "variables" scope > to share between methods. Right? > > And, if that's so, I guess each form variable has to be established in > the first validation > method by translating each piece of data in to the variable scope with > in order to share those > variables within a CFC. > > Am I correct? > > Thanks for the feedback. > > Rick > > Dominic Watson wrote: >> Something like this? >> >> >> > anotherObject.doSomethingWithForm(argumentCollection = form) /> >> >> Form did not validate >> >> >> Or, are you wanting to pass the form data to another cfc method from >> within the validation method? If so, something like this: >> >> >> >> >> >> >> ... >> someOtherObject.doSomethingWithFormData( argumentCollection = >> arguments ) ; >> ... >> >> >> >> Dominic >> >> 2008/11/1 Rick Faircloth <[EMAIL PROTECTED]>: >> >>> Hi, all... >>> >>> Can form variables be passed around between a calling page and >>> multiple cfc's? >>> >>> I have a form with data I want to validate, then generate an email with. >>> >>> I have the calling page with the form, which sends the form data via >>> argumentCollection, >>> to a form_validation.cfc. If the form data passes validation, then I >>> want to send the form >>> data to an email_processing.cfc for email generation. >>> >>> Would the form variables be available to the calling page and both cfc's >>> in this case? >>> Or do I need to create session variables or another type of variable to >>> pass the values >>> around? >>> >>> Thanks, >>> >>> Rick >>> >>> >>> >> >> > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314719 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC and Form Variables Question
Hi, Dominic and thanks for the reply... The second option sounds more like what I'm wanting to do. And while reading your response, it occurred to me that if I send the form data to a cfc for validation, and it validates, I could just go straight to another method (how about to another cfc?) for the email processing without going back to the orginal form page and then to the email processing cfc. (make sense?) So, I would go from form page to validation method, and if all validates, straight to the email method to send emails. And from your description below, I would just refer to the arguments.variables in the second method as in the first? No, I guess I couldn't use the "arguments" scope and share variables between methods...I'd need to put the data into the "variables" scope to share between methods. Right? And, if that's so, I guess each form variable has to be established in the first validation method by translating each piece of data in to the variable scope with in order to share those variables within a CFC. Am I correct? Thanks for the feedback. Rick Dominic Watson wrote: > Something like this? > > > anotherObject.doSomethingWithForm(argumentCollection = form) /> > > Form did not validate > > > Or, are you wanting to pass the form data to another cfc method from > within the validation method? If so, something like this: > > > > > > > ... > someOtherObject.doSomethingWithFormData( argumentCollection = > arguments ) ; > ... > > > > Dominic > > 2008/11/1 Rick Faircloth <[EMAIL PROTECTED]>: > >> Hi, all... >> >> Can form variables be passed around between a calling page and >> multiple cfc's? >> >> I have a form with data I want to validate, then generate an email with. >> >> I have the calling page with the form, which sends the form data via >> argumentCollection, >> to a form_validation.cfc. If the form data passes validation, then I >> want to send the form >> data to an email_processing.cfc for email generation. >> >> Would the form variables be available to the calling page and both cfc's >> in this case? >> Or do I need to create session variables or another type of variable to >> pass the values >> around? >> >> Thanks, >> >> Rick >> >> >> > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314718 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC and Form Variables Question
Something like this? Form did not validate Or, are you wanting to pass the form data to another cfc method from within the validation method? If so, something like this: ... someOtherObject.doSomethingWithFormData( argumentCollection = arguments ) ; ... Dominic 2008/11/1 Rick Faircloth <[EMAIL PROTECTED]>: > Hi, all... > > Can form variables be passed around between a calling page and > multiple cfc's? > > I have a form with data I want to validate, then generate an email with. > > I have the calling page with the form, which sends the form data via > argumentCollection, > to a form_validation.cfc. If the form data passes validation, then I > want to send the form > data to an email_processing.cfc for email generation. > > Would the form variables be available to the calling page and both cfc's > in this case? > Or do I need to create session variables or another type of variable to > pass the values > around? > > Thanks, > > Rick > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314716 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
CFC and Form Variables Question
Hi, all... Can form variables be passed around between a calling page and multiple cfc's? I have a form with data I want to validate, then generate an email with. I have the calling page with the form, which sends the form data via argumentCollection, to a form_validation.cfc. If the form data passes validation, then I want to send the form data to an email_processing.cfc for email generation. Would the form variables be available to the calling page and both cfc's in this case? Or do I need to create session variables or another type of variable to pass the values around? Thanks, Rick ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314713 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: cfreturn "2" query values from CFC?
Thanks for the tip, Adrian! Rick Adrian Lynch wrote: > This: > > > > > > > > > Or this: > > > > > > > > > Should do it. > > Adrian > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314599 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: cfreturn "2" query values from CFC?
This: Or this: Should do it. Adrian Building a database of ColdFusion errors at http://cferror.org/ -Original Message- From: Rick Faircloth Sent: 30 October 2008 01:30 To: cf-talk Subject: cfreturn "2" query values from CFC? Hi, all... If I'm running two queries inside a function, how do I return both query values? Query 1: get_properties Query 2: get_all_photos Can there be two cfreturn's? or, perhaps, ??? Rick ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314595 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: cfreturn "2" query values from CFC?
Thanks, Charlie... makes sense. I guess I could also just run two functions within each cfcase, as well... Rick Charlie Griefer wrote: > put 'em in a struct and return the struct. > > > > > > > > > > > > > > > On Wed, Oct 29, 2008 at 6:29 PM, Rick Faircloth <[EMAIL PROTECTED]>wrote: > > >> Hi, all... >> >> If I'm running two queries inside a function, >> how do I return both query values? >> >> Query 1: get_properties >> Query 2: get_all_photos >> >> >> >> >> Can there be two cfreturn's? >> >> or, perhaps, >> >> ??? >> >> Rick >> >> >> > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314587 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: cfreturn "2" query values from CFC?
put 'em in a struct and return the struct. On Wed, Oct 29, 2008 at 6:29 PM, Rick Faircloth <[EMAIL PROTECTED]>wrote: > Hi, all... > > If I'm running two queries inside a function, > how do I return both query values? > > Query 1: get_properties > Query 2: get_all_photos > > > > > Can there be two cfreturn's? > > or, perhaps, > > ??? > > Rick > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314586 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
cfreturn "2" query values from CFC?
Hi, all... If I'm running two queries inside a function, how do I return both query values? Query 1: get_properties Query 2: get_all_photos Can there be two cfreturn's? or, perhaps, ??? Rick ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314584 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Help me understand CFC performance
> Right now, I'm giving serious thought to breaking the SQL CFC up into > multiple separate CFC's (one for each primary area of functionality); > i.e. one CFC for the content management section, one for logging, one > for user management/login/etc., etc. which would leave me with about > 10 separate CFC's but would have me touching every single page that > calls the SQL CFC (I'm using cfinvoke). Hi Pete, I'd recommend that approach in general, but not specifically for performance reasons. I'd be more concerned about breaking it up into separate components mostly because the one you have is 4,000 lines. Although I know there are people who maintain code of that size I've never considered it a "best practice". Aside from the fact that some editors have a difficult time handling large files like that, it also makes swapping out discrete behaviors more difficult because the way to swap out some alternative logging functionality for a specific client (as a random example) would mean extending that CFC with not just the logging, but all the other stuff also. And for me personally I just find editing really large files to be kind of frustrating. I generally start looking for ways to split them up once I get over a few hundred lines. However, splitting them up doesn't necessarily have to involve editing all the rest of your app. There are some tricks you can try to make the component you have remain the "black box" facade through which data access happens. One way you might try if you're using CF8 is to use onMissingMethod to dynamically load the individual functions. Then put each method in its own file in the same directory and viola! Lazy-loading methods. I haven't tested this sample code at all, but the onTap framework does something similar for its libraries. So this ought to work after a little testing if you want to go that route. You might want to leave a few of the most frequently used functions in the original CFC though, because pulling them out like this adds to the load time when the method is called -- so the ones that are most likely to execute on each request will load faster if you leave them in. hth -- s. isaac dealey ^ new epoch isn't it time for a change? ph: 781.769.0723 http://onTap.riaforge.org/blog ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314380 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Help me understand CFC performance
It's worked very well, but >there's a problem -- when the site initially loads, it takes forever (well, >about 30 seconds). I'm assuming that this is because the SQL CFC has grown >to almost 4,000 lines of code. > But that's only when the app first loads. And I think your application variables should be stored for 7 days, as an average (I think?) Does it really matter that much, since the rest of the time, the pages will load quickly? Will ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314379 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Help me understand CFC performance
I've got a bit of an issue with the site code (more or less a content management system) that I've been adding to over the past several years. The core of my code is a CFC that contains all of my SQL operations in separate functions. I went with this approach for a number of reasons: it pulls the SQL out of the presentation layer, it takes a "black box" approach so that I can switch from SQL to stored procedures, or views, etc., and it allows me to support different database types. It's worked very well, but there's a problem -- when the site initially loads, it takes forever (well, about 30 seconds). I'm assuming that this is because the SQL CFC has grown to almost 4,000 lines of code. Right now, I'm giving serious thought to breaking the SQL CFC up into multiple separate CFC's (one for each primary area of functionality); i.e. one CFC for the content management section, one for logging, one for user management/login/etc., etc. which would leave me with about 10 separate CFC's but would have me touching every single page that calls the SQL CFC (I'm using cfinvoke). Will this yield me the performance improvements that I'm looking for? Are there any best practices for CFC performance? Thanks, Pete ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314378 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: basic cfc/oo design question
>Larry, >Awesome. Thanx. > >Do you know if the Poseidon UML Community version will export an XMI 1.1 >file? > >~G~ > >If not any recommendations for a OSS and/or Free UML App? > > >From what I understand Brian developed the app using Poseidon UML. So yes I >assume it would work. As for UML reccomendations, I mostly use the UML plugin for myEclipse ($30 a year) and Magic Draw (much more expensive). There's also ArgoUML which is FOSS http://argouml.tigris.org/ regards, larry ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314374 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: basic cfc/oo design question
Larry, Awesome. Thanx. Do you know if the Poseidon UML Community version will export an XMI 1.1 file? ~G~ If not any recommendations for a OSS and/or Free UML App? On Fri, Oct 24, 2008 at 4:19 PM, Larry Lyons <[EMAIL PROTECTED]> wrote: > >All fine point there Gerald, thank you. I've looked at Illudium in the > >past and plan on doing so again for this project. Right now though I'm > >trying to map out all my classes in UML to make sure that I have it > >together conceptually, then move to the actual coding part. The > >database already exists from the previous iteration of the project > >though I plan on modifying parts of it. So I will most likely start at > >the conceptual level and work down, then start generating from the > >persistence level and work up, then try and hopefully meet those two > >somewhere in a happy middle :) > > > >Judah > > Judah, > > You may want to check out Brian Kotek's CFCStubGenerator, > http://cfcstub.riaforge.org/. Basically what you do is develop your class > diagram in your favourite UML app. Then export it as an XMI 1.1 file. Next > run the CFCStubGenerator app and import your xmi file. The stub generator > will output stubs with all you CFC's, as well as many other useful stuff > (xml files for MG and Coldspring, test cases for CFCUnit or CFUnit etc.). > > hth, > larry > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314358 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: basic cfc/oo design question
>All fine point there Gerald, thank you. I've looked at Illudium in the >past and plan on doing so again for this project. Right now though I'm >trying to map out all my classes in UML to make sure that I have it >together conceptually, then move to the actual coding part. The >database already exists from the previous iteration of the project >though I plan on modifying parts of it. So I will most likely start at >the conceptual level and work down, then start generating from the >persistence level and work up, then try and hopefully meet those two >somewhere in a happy middle :) > >Judah Judah, You may want to check out Brian Kotek's CFCStubGenerator, http://cfcstub.riaforge.org/. Basically what you do is develop your class diagram in your favourite UML app. Then export it as an XMI 1.1 file. Next run the CFCStubGenerator app and import your xmi file. The stub generator will output stubs with all you CFC's, as well as many other useful stuff (xml files for MG and Coldspring, test cases for CFCUnit or CFUnit etc.). hth, larry ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314355 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: basic cfc/oo design question
as an extra helper i would say if you are migrating from procedural to OO i would suggest MG, as it is fantastic and forces you down an OO route. i havent done too much research on the others but when i was deciding, i posted a message on this forum and was told that MG is def more OO than others >I'm planning on using one of the MVC frameworks (probably MG, but I'll >look at Mach ii and OO Fusebox again as well) for a seperate project >that can be built from the ground up. This project has enough quirks >(like an existing url rewriter scheme) that I'd prefer not to try and >shoehorn in a whole framework. > >I agree though that having a framework that you make yourself use will >certainly aid in getting it "down". > >As for the getters/setters, I just read a posting and comments >discussion on Brian Kotek's blog that helps clarify the getter/setter >argument and I think I'll go ahead and do the extra work for >getters/setters. > >Thanks, >Judah > > >> ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314338 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: How do I use a CFC for form data validation?
the keys in the struct that comprises the argumentCollection are received by the method as individual cfarguments. so if your form struct has keys 'firstName' and 'lastName', and the form was passed in as an argumentCollection, you'd have arguments.firstName and arguments.lastName. also you need to var that it also -might- not be a bad idea, if only for documentation purposes, to specify your cfarguments inside of the cffunction. so you'd have: On Wed, Oct 22, 2008 at 7:20 PM, Rick Faircloth <[EMAIL PROTECTED]>wrote: > I've been trying to figure out how to use a CFC for validating form > data, but I can't find any info on how the code should be constructed. > > I've been using the CFC and the form variables in the code, but I'm > trying to get away from accessing data directly in the CFC. > > The invocation I'm using: > >method = > "validate_comment_data" > argumentCollection = "form" > output = "false" > access = "public" > returnVariable = "form_errors"> > > Then I just use the CFC like this: > > displayname = "validate_comment_data" >hint= "Validate comment form data > before inserting or updating" >output= "false" >access = "public"> > > > > > > > > > > > > etc > > > > > > But how would I change the cffunction code to make use of the > argumentCollection = "form" > variables? > > ??? > > Some clues for the clueless, anyone? > > Thanks, > > Rick > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314283 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
How do I use a CFC for form data validation?
I've been trying to figure out how to use a CFC for validating form data, but I can't find any info on how the code should be constructed. I've been using the CFC and the form variables in the code, but I'm trying to get away from accessing data directly in the CFC. The invocation I'm using: Then I just use the CFC like this: etc But how would I change the cffunction code to make use of the argumentCollection = "form" variables? ??? Some clues for the clueless, anyone? Thanks, Rick ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314282 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How can this CFC be improved?
Now *that* would be scary this close to Halloween! :oP Dawson, Michael wrote: > Oh, and VAR your variables!!! > > If you don't, Ray Camden will be knocking at your door. > > Mike > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314272 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: How can this CFC be improved?
Oh, and VAR your variables!!! If you don't, Ray Camden will be knocking at your door. Mike -Original Message- From: Rick Faircloth [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 22, 2008 1:26 PM To: cf-talk Subject: Re: How can this CFC be improved? I think I can handle that approach and stay sane! :o) ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314271 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How can this CFC be improved?
I think I can handle that approach and stay sane! :o) Charlie Griefer wrote: > For now I probably wouldn't worry about DAOs and other related concepts. > Build a strong foundation by encapsulating the CFC methods so that they > don't rely on any external variables. That'd be a good start. > Once you recoil in terror at seeing a CFC method reference application or > session or form or (etc), then you're ready to take the next step :) > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314269 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How can this CFC be improved?
For now I probably wouldn't worry about DAOs and other related concepts. Build a strong foundation by encapsulating the CFC methods so that they don't rely on any external variables. That'd be a good start. Once you recoil in terror at seeing a CFC method reference application or session or form or (etc), then you're ready to take the next step :) On Wed, Oct 22, 2008 at 11:09 AM, Rick Faircloth <[EMAIL PROTECTED]>wrote: > Thanks for the overview, Mike. > > I see what everyone's saying about the encapsulation. I'm just trying to > make all the pieces of the puzzle fit. Your tutorial was helpful. It > was a little > advanced in some respects. I just needed to approach the CFC's a little > more carefully, until I could figure out what was going on, before trying > to > really understand the DAO approach. > > I'm sure to have a "eureka" moment at some point, with everyone's help..and > I'm sure it'll be on a Sunday night...my "honey, don't forget to take > out the garbage" night! :o) > > Rick > > Mike Kear wrote: > > Rick, imagine how it would be if (as is fairly common) you have > > business objects (beans) handling single items, and DAO cfcs handling > > all the database interaction back and forth.This is the scenario i > > drew in the tutorials I wrote ... > > > > So in the application scope you have a DAO - just one . sitting in > > RAM waiting to be called on. And as people come and go through the > > site they're causing beans to be created all over hte place to > > manipulate the things they're needing as they move around. > > > > If (as happens frequently in one of my sites) there are 400 > > concurrent users, and only one DAO for this applicatoin, imagine how > > many people are likely to be simultaneously using an "Add()" method in > > the DAO. In those circumstances it's absolutly essential that the > > methods in teh DAO to e threadsafe. That means ALL variables inside > > the methods have to be var'd unless there is a specific reason not to. > > It means you have to build teh DAO carefully so data from one user > > doesn't interfere with the data from the others. But that's also true > > if you only have 3 simultaneous users. You still dont want their > > information - maybe their shopping carts getting intermingled. > > > > But on the other hand if you dont have the DAO sitting in the > > application scope, every time anyone uses that part of the > > application, the DAO has to be instantiated again.There's an > > overhead processing price to pay for doing that. > > > > Here's my rule of thumb. Vary away from it only once you realise > > the implications ... never require a cfc to know anything about the > > outside world. Anything it needs to know, you'll tell it. So > > that means you tell it what the dsn is. you dont ask it to go look > > in the application vars for it. You tell ilt what the different > > values are for the arguments, either by passing in a struct such as > > form struct or by passing in the values individually or by passing in > > a bean. But the cfc doesnt have to go looking for it, and doesnt > > have to know where it came from > > > > This is exactly how most of the built-in functions in coldfusion work. > >The function replace() doesnt have to know anything - you give it > > the information it needs to do its job.the replace() function > > doesnt do much - it does a limited job quickly and efficiently but > > its a small job.that's how to design your methods in you own cfcs > > - small limited functions that dont know anything about the outside > > world apart from what you tell it, and they should be threadsafe so > > you dont have to use up all your ram and processing power with > > bazillions of copies of the same code running at once. > > > > Hope this helps I rather have the feeling that at the moment > > you're thinking the stuff i put in my tutorial is a lot of additional > > typing - it's all too hard and too much work. That's not a problem > > - it was for me too until suddenly the light went on and i had a few > > of those "EUREKA!!" moments. I can disctinctly remember the day i > > finally 'got it' about encapsulation.I was so excited i made the > > mistake of talking about it in an agitated manner to my wife to > > promptly told me to stop being so bloody stupid and put the garbage > > out cos it's garbage night.
Re: How can this CFC be improved?
Sounds like a good approach. I'm about to duplicate much of the work I've done on a recent project for another client and I plan to use CFC's instead of putting the code into my .cfm's. (I wouldn't call what I'm going to do "OOP"... :oP) But since I've already written the code procedurally once, it should be easier to see how to adapt it. Rick Dawson, Michael wrote: > On a recent project, I built the entire codebase using linear code > (non-OOP). It was faster for me to see what data I actually needed that > way. > > I considered this my prototype. > > Then, once I was satisfied with the project, I started to refactor my > code. I put all queries into a single CFC. I put all paper receipt > generation code into yet another CFC. > > That sure cut down on the amount of code in my main .cfm page > (controller). > > However, I noticed a few other places that could be optimized. > > So, I created a service CFC that handled all interaction between the > data CFC and the receipt CFC. The only weird part is that some of the > service CFC methods only call the database CFC methods. In fact, I used > the same method names in both CFCs. I did this because I wanted my main > ..cfm page to ONLY interact with the service CFC and not the database > CFC. > > Finally, in my main .cfm page, I was left with only a cfswitch block. > Each cfcase tag merely called on the service CFC to perform its tasks. > > This was great because I actually felt good about the code. Also, I > could fully-test each CFC and method, separately. > > Therefore, my approach was to build a low-tech prototype, then see where > I could move specific logic from the main .cfm. > > It took a couple of iterations, but it works fine and it's easy enough > to maintain. > > Mike > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314266 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: How can this CFC be improved?
Thanks for the overview, Mike. I see what everyone's saying about the encapsulation. I'm just trying to make all the pieces of the puzzle fit. Your tutorial was helpful. It was a little advanced in some respects. I just needed to approach the CFC's a little more carefully, until I could figure out what was going on, before trying to really understand the DAO approach. I'm sure to have a "eureka" moment at some point, with everyone's help..and I'm sure it'll be on a Sunday night...my "honey, don't forget to take out the garbage" night! :o) Rick Mike Kear wrote: > Rick, imagine how it would be if (as is fairly common) you have > business objects (beans) handling single items, and DAO cfcs handling > all the database interaction back and forth.This is the scenario i > drew in the tutorials I wrote ... > > So in the application scope you have a DAO - just one . sitting in > RAM waiting to be called on. And as people come and go through the > site they're causing beans to be created all over hte place to > manipulate the things they're needing as they move around. > > If (as happens frequently in one of my sites) there are 400 > concurrent users, and only one DAO for this applicatoin, imagine how > many people are likely to be simultaneously using an "Add()" method in > the DAO. In those circumstances it's absolutly essential that the > methods in teh DAO to e threadsafe. That means ALL variables inside > the methods have to be var'd unless there is a specific reason not to. > It means you have to build teh DAO carefully so data from one user > doesn't interfere with the data from the others. But that's also true > if you only have 3 simultaneous users. You still dont want their > information - maybe their shopping carts getting intermingled. > > But on the other hand if you dont have the DAO sitting in the > application scope, every time anyone uses that part of the > application, the DAO has to be instantiated again.There's an > overhead processing price to pay for doing that. > > Here's my rule of thumb. Vary away from it only once you realise > the implications ... never require a cfc to know anything about the > outside world. Anything it needs to know, you'll tell it. So > that means you tell it what the dsn is. you dont ask it to go look > in the application vars for it. You tell ilt what the different > values are for the arguments, either by passing in a struct such as > form struct or by passing in the values individually or by passing in > a bean. But the cfc doesnt have to go looking for it, and doesnt > have to know where it came from > > This is exactly how most of the built-in functions in coldfusion work. >The function replace() doesnt have to know anything - you give it > the information it needs to do its job.the replace() function > doesnt do much - it does a limited job quickly and efficiently but > its a small job.that's how to design your methods in you own cfcs > - small limited functions that dont know anything about the outside > world apart from what you tell it, and they should be threadsafe so > you dont have to use up all your ram and processing power with > bazillions of copies of the same code running at once. > > Hope this helps I rather have the feeling that at the moment > you're thinking the stuff i put in my tutorial is a lot of additional > typing - it's all too hard and too much work. That's not a problem > - it was for me too until suddenly the light went on and i had a few > of those "EUREKA!!" moments. I can disctinctly remember the day i > finally 'got it' about encapsulation.I was so excited i made the > mistake of talking about it in an agitated manner to my wife to > promptly told me to stop being so bloody stupid and put the garbage > out cos it's garbage night. > > > Cheers > Mike Kear > Windsor, NSW, Australia > Adobe Certified Advanced ColdFusion Developer > AFP Webworks > http://afpwebworks.com > ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month > > > > On Thu, Oct 23, 2008 at 3:39 AM, Rick Faircloth > <[EMAIL PROTECTED]> wrote: > >> I think I'm beginning to understand your reasoning. >> It's just taking some time for me to get to the "best practices" of CFC >> usage. >> Trying to get "anything" to work at first keeps my projects moving, while >> beginning to employ different coding techniques. I'm basically trying to >> learn by writing code for projects that are going live with these updates >> as soon as I
Re: basic cfc/oo design question
Agreed, this is something I ran into before and is definitely something that often haunts me into indecision. That is one of the reasons I'm not doing a framework right now. I figure if I can abstract out my functionality into a set of classes and get those classes implemented as cfc's, I'll have done plenty for a first go around. Then I can move onto a framework for the next, more discrete, project and try to increase my OO-indoctrination depth. Judah On Wed, Oct 22, 2008 at 10:43 AM, Gerald Guido <[EMAIL PROTECTED]> wrote: > One thing I would watch out for is concept overload. I think the single most > difficult thing for me was sifting the VAST amounts of information. One of > the problems I ran into was finding tutes and examples that did *one thing > only* and not mixing concepts like using MachII and ColdSpring together. So > when you look at the code examples you can't figure out which parts were > MachII and which were ColdSpring. > > I would recomend taking things one step at a time instead of trying to > abstract your database while trying to work it into a Framework. I ended up > thinking myself stupid and just got frustrated. Pick a single task/Concept > and figure it out and then move on to another. > > HTH > G > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314262 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: basic cfc/oo design question
One thing I would watch out for is concept overload. I think the single most difficult thing for me was sifting the VAST amounts of information. One of the problems I ran into was finding tutes and examples that did *one thing only* and not mixing concepts like using MachII and ColdSpring together. So when you look at the code examples you can't figure out which parts were MachII and which were ColdSpring. I would recomend taking things one step at a time instead of trying to abstract your database while trying to work it into a Framework. I ended up thinking myself stupid and just got frustrated. Pick a single task/Concept and figure it out and then move on to another. HTH G On Wed, Oct 22, 2008 at 12:57 PM, Judah McAuley <[EMAIL PROTECTED]>wrote: > All fine point there Gerald, thank you. I've looked at Illudium in the > past and plan on doing so again for this project. Right now though I'm > trying to map out all my classes in UML to make sure that I have it > together conceptually, then move to the actual coding part. The > database already exists from the previous iteration of the project > though I plan on modifying parts of it. So I will most likely start at > the conceptual level and work down, then start generating from the > persistence level and work up, then try and hopefully meet those two > somewhere in a happy middle :) > > Judah > > -- Gerald Guido http://www.myinternetisbroken.com "Neurotics build castles in the air, psychotics live in them. My mother cleans them." -- Rita Rudner ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314261 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: basic cfc/oo design question
Just to make sure you're aware of its existence, I would suggest taking a look at ColdBox as well. http://www.coldboxframework.com/ http://www.12robots.com/index.cfm/2008/9/21/Building-an-Application-with-ColdBox-and-ColdSpring--Part-1 On Wed, Oct 22, 2008 at 12:02 PM, Judah McAuley wrote: > I'm planning on using one of the MVC frameworks (probably MG, but I'll > look at Mach ii and OO Fusebox again as well) for a seperate project > that can be built from the ground up. This project has enough quirks > (like an existing url rewriter scheme) that I'd prefer not to try and > shoehorn in a whole framework. > > I agree though that having a framework that you make yourself use will > certainly aid in getting it "down". > > As for the getters/setters, I just read a posting and comments > discussion on Brian Kotek's blog that helps clarify the getter/setter > argument and I think I'll go ahead and do the extra work for > getters/setters. > > Thanks, > Judah > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314259 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: How can this CFC be improved?
On a recent project, I built the entire codebase using linear code (non-OOP). It was faster for me to see what data I actually needed that way. I considered this my prototype. Then, once I was satisfied with the project, I started to refactor my code. I put all queries into a single CFC. I put all paper receipt generation code into yet another CFC. That sure cut down on the amount of code in my main .cfm page (controller). However, I noticed a few other places that could be optimized. So, I created a service CFC that handled all interaction between the data CFC and the receipt CFC. The only weird part is that some of the service CFC methods only call the database CFC methods. In fact, I used the same method names in both CFCs. I did this because I wanted my main ..cfm page to ONLY interact with the service CFC and not the database CFC. Finally, in my main .cfm page, I was left with only a cfswitch block. Each cfcase tag merely called on the service CFC to perform its tasks. This was great because I actually felt good about the code. Also, I could fully-test each CFC and method, separately. Therefore, my approach was to build a low-tech prototype, then see where I could move specific logic from the main .cfm. It took a couple of iterations, but it works fine and it's easy enough to maintain. Mike -Original Message- From: Rick Faircloth [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 22, 2008 10:39 AM To: cf-talk Subject: Re: How can this CFC be improved? I think I'm beginning to understand your reasoning. It's just taking some time for me to get to the "best practices" of CFC usage. Trying to get "anything" to work at first keeps my projects moving, while beginning to employ different coding techniques. I'm basically trying to learn by writing code for projects that are going live with these updates as soon as I can get them working...too busy for much practice. Also, I'm a solo developer and never plan to code while working for anyone else..so as far as sharing code or compensation, it doesn't matter. My client's don't care, as long as the correct data shows up on their pages. But I am trying to figure out the best way to do all of this. Thanks, Rick ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314258 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How can this CFC be improved?
Rick, imagine how it would be if (as is fairly common) you have business objects (beans) handling single items, and DAO cfcs handling all the database interaction back and forth.This is the scenario i drew in the tutorials I wrote ... So in the application scope you have a DAO - just one . sitting in RAM waiting to be called on. And as people come and go through the site they're causing beans to be created all over hte place to manipulate the things they're needing as they move around. If (as happens frequently in one of my sites) there are 400 concurrent users, and only one DAO for this applicatoin, imagine how many people are likely to be simultaneously using an "Add()" method in the DAO. In those circumstances it's absolutly essential that the methods in teh DAO to e threadsafe. That means ALL variables inside the methods have to be var'd unless there is a specific reason not to. It means you have to build teh DAO carefully so data from one user doesn't interfere with the data from the others. But that's also true if you only have 3 simultaneous users. You still dont want their information - maybe their shopping carts getting intermingled. But on the other hand if you dont have the DAO sitting in the application scope, every time anyone uses that part of the application, the DAO has to be instantiated again.There's an overhead processing price to pay for doing that. Here's my rule of thumb. Vary away from it only once you realise the implications ... never require a cfc to know anything about the outside world. Anything it needs to know, you'll tell it. So that means you tell it what the dsn is. you dont ask it to go look in the application vars for it. You tell ilt what the different values are for the arguments, either by passing in a struct such as form struct or by passing in the values individually or by passing in a bean. But the cfc doesnt have to go looking for it, and doesnt have to know where it came from This is exactly how most of the built-in functions in coldfusion work. The function replace() doesnt have to know anything - you give it the information it needs to do its job.the replace() function doesnt do much - it does a limited job quickly and efficiently but its a small job.that's how to design your methods in you own cfcs - small limited functions that dont know anything about the outside world apart from what you tell it, and they should be threadsafe so you dont have to use up all your ram and processing power with bazillions of copies of the same code running at once. Hope this helps I rather have the feeling that at the moment you're thinking the stuff i put in my tutorial is a lot of additional typing - it's all too hard and too much work. That's not a problem - it was for me too until suddenly the light went on and i had a few of those "EUREKA!!" moments. I can disctinctly remember the day i finally 'got it' about encapsulation.I was so excited i made the mistake of talking about it in an agitated manner to my wife to promptly told me to stop being so bloody stupid and put the garbage out cos it's garbage night. Cheers Mike Kear Windsor, NSW, Australia Adobe Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month On Thu, Oct 23, 2008 at 3:39 AM, Rick Faircloth <[EMAIL PROTECTED]> wrote: > I think I'm beginning to understand your reasoning. > It's just taking some time for me to get to the "best practices" of CFC > usage. > Trying to get "anything" to work at first keeps my projects moving, while > beginning to employ different coding techniques. I'm basically trying to > learn by writing code for projects that are going live with these updates > as soon as I can get them working...too busy for much practice. > > Also, I'm a solo developer and never plan to code while working for anyone > else..so as far as sharing code or compensation, it doesn't matter. My > client's > don't care, as long as the correct data shows up on their pages. > > But I am trying to figure out the best way to do all of this. > > Thanks, > > Rick > > Dawson, Michael wrote: >> Technically, they both will work. >> >> However, what if you have a different process of calling the same >> function that doesn't use the form scope? >> >> What if you want to call the same method as a web service? >> >> Your current system will fail at that time. >> >> >> Of course, if you fully control your code and no one else will ever use >> it, then do what you think works best for you. >> >> I have some code that might not pass the approval of several pe
Re: basic cfc/oo design question
I'm planning on using one of the MVC frameworks (probably MG, but I'll look at Mach ii and OO Fusebox again as well) for a seperate project that can be built from the ground up. This project has enough quirks (like an existing url rewriter scheme) that I'd prefer not to try and shoehorn in a whole framework. I agree though that having a framework that you make yourself use will certainly aid in getting it "down". As for the getters/setters, I just read a posting and comments discussion on Brian Kotek's blog that helps clarify the getter/setter argument and I think I'll go ahead and do the extra work for getters/setters. Thanks, Judah On Tue, Oct 21, 2008 at 4:56 PM, Richard White <[EMAIL PROTECTED]> wrote: > i know you said you are not using frameworks but i recently done exactly what > you are doing (migrating procedural to OO) and tore my hair out not > understanding best practice etc..., as i suspect you are going through now > > then someone on this forum told me to look into ModelGlue and ColdSpring > frameworks and all i can say is that it made it so simple for me to > understand. it guides you to understanding best practices, and gives you no > choice but to program in OO > > you may think that it would take longer if you were to go into a framework > first but it actually makes it easier. i sat down with a colleague without > knowing anything about modelglue and coldspring and within 1 month we had > learned it, and completely redesigned our app based on OO. > > in relation to your question, i use getters and setters and i have seen this > much more widely used that the other you pointed out > > hope this helps > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314255 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: basic cfc/oo design question
Thanks for this advice Mike. I'd forgotten about the cfcdev mailing list, I'll go sign up for that now. Fortunately for me, this site is not a high traffic site. These are back end business process tools, so I'm really refactoring to increase the sensibility and maintainability of the code. I will hopefully also be getting some other developer resources on this project in the future and they will likely be either C# or Java guys, so moving to a more OO framework will make it easier to bring them on I think. Judah On Tue, Oct 21, 2008 at 4:29 PM, Mike Chabot <[EMAIL PROTECTED]> wrote: > This is a very big topic and you might get a more in-depth response if > you posted your question on the cfcdev list, which focuses on CFCs and > OOP. > > A word of caution though if you are approaching OOP for the first time > is that CF isn't an ideal OOP language. Your rewrite might end up > doing more harm than good if you aren't careful, especially if it is a > high-traffic site. The code I write in Java and .NET isn't code that I > would write in ColdFusion. In my experience, ColdFusion suffers > significant performance and RAM hits when you instantiate numerous > objects, even simple ones, unless you instantiate them using Java code > embedded inside of CF. To counteract this performance hit I favor > light-weight pseudo Data Transfer Objects or pseudo Value Objects > which focus on data storage, and move the functions to helper classes. > By "pseudo" I mean structures (StructNew() type structures) that > mirror DTOs or VOs that you can cast to object instances if necessary. > Again, I do this because CF isn't good at handling objects and I find > this technique to work well given that limitation, not because this is > the purest OOP way to do things. There are plenty of healthy > discussions on the best techniques in the cfcdev mailing list > archives. If you prefer a pure OOP design for your site I think you > will find ColdFusion to be limiting as you dig deeper into this topic. > > -Mike Chabot > > On Tue, Oct 21, 2008 at 6:35 PM, Judah McAuley <[EMAIL PROTECTED]> wrote: >> I'm migrating the backend portion of an application from a procedural >> set of code to a cfc-based and hopefully more OO oriented design. For >> this first go around I won't be using any of the MVC frameworks (the >> front end is already written on this project) and I don't plan on >> using any of the ORM's like Transfer quite yet. >> >> Right now I'm sitting down and listing all the classes I'm going to >> need and sketching out their methods and I've come up against a best >> practices question. >> >> Lets say I have a User object. The user has properties of id, first >> name, last name, company and date of birth lets say. >> >> Some setups I've seen would write a getter/setter (accessor/mutator) >> for each property in that object along with a method to retrieve a >> whole object and a set of objects. (at this point I'm using the words >> object, bean and class interchangeably. I understand that I might be a >> bit off there). So if I wanted to display a user with the id 10, I'd >> say currentuser = User.getUser(10) which would return a struct with >> the User object (bean, whatever). Then if I wanted that user's name, >> I'd say currentuser.getFirstName(). If I wanted to change that users >> first name to Bob, I'd say currentuser.setFirstName('Bob') >> >> Other setups I've seen don't seem to write getters and setters for >> each property but rather create methods that act on the object level. >> So I'd say currentuser = User.getUser(10) and then if I wanted that >> persons first name, I'd just reference it as currentuser.first_name >> and if I wanted to set his name to Bob, I'd say currentuser.first_name >> = 'Bob' and then call User.saveUser(10) and let it persist the change >> that I made to the struct. >> >> Is there a consensus on the best way to approach this? What are the >> most useful tutorials out there for someone setting up their first go >> around with OO while not using a framework? >> >> Thanks, >> Judah >> >> > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314254 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: basic cfc/oo design question
All fine point there Gerald, thank you. I've looked at Illudium in the past and plan on doing so again for this project. Right now though I'm trying to map out all my classes in UML to make sure that I have it together conceptually, then move to the actual coding part. The database already exists from the previous iteration of the project though I plan on modifying parts of it. So I will most likely start at the conceptual level and work down, then start generating from the persistence level and work up, then try and hopefully meet those two somewhere in a happy middle :) Judah On Tue, Oct 21, 2008 at 5:33 PM, Gerald Guido <[EMAIL PROTECTED]> wrote: >>>Your rewrite might end up doing more harm than good if you aren't careful, > > > That reminds me of a comment by Sean Corfield on the alagad blog: > "And a bad OO design will punish you more than any bad procedural design > you've ever conceived." > > http://www.alagad.com/go/blog-entry/what-does-object-oriented-programming-do-for-me > > I know what he meant first hand ;-). OO can be a *harsh* master. > > Not to detour you from the pursuit but it will take time. In an interview, > Hal Helms said that it takes about 6-12 months to make the transition to OO. > I have been beating my head against OO for the last 18 months and it started > to really pay off after about 6-7 months. It WILL pay off, you just need to > keep at it. After a shile you just stert seeing thing differently. It is a > restructuring of how you think and approach programming. They call it > "cognitive restructuring" in psychology. > > As for what to do? Start *doing*: research, read, learn, try, screw up, ask > questions, learn some more, rinse. Repeat as needed. > > Go check out Ben Nadel's series on OO. > http://www.bennadel.com/blog/1275-OOPhoto-Another-Attempt-At-Learning-Object-Oriented-Programming-OOP-In-ColdFusion.htm > > What I did was to try to figure out how to use (abstract my database) the > Illudium PU-36 Code Generator. That helped me set a goal and get over the > initial hurtle in a pragmatic manner. > > http://code.google.com/p/cfcgenerator/ > > Where my head is at these days is to abstract everything to it's most basic > form. Like Einstein said "Everything should be as simple as it is, but not > simpler." > > HTH... Best of luck. > > G > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314253 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How to avoid "is not of type query" error using CFC?
Got it. Thanks, Ian. Rick Ian Skinner wrote: > Rick Faircloth wrote: > >> Now I know. The cfreturn variable has to match the query name. >> > > Well, no. It has to match what you want to return. Sure there are lots > of examples where the return does not match the query name because the > query is not what is necessarily returned. But if your function is > simple and is just returning the query then yes, the return should match > the query name. > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314251 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How to avoid "is not of type query" error using CFC?
All cleared up... thanks, Charlie. Rick Charlie Griefer wrote: > the return variable has to match whatever it is you want to return. in > *this* case, it's the query. > let's say you just wanted to return a recordcount... then the return > variable wouldn't match the query name. it'd match a variable name: > > > > > > > > SELECT * FROM foo WHERE bar = 1 > > > > > > > > for what it's worth, the function above doesn't need the 'howMany' variable. > you can simply . just trying to illustrate > the use of variable names for you. > > also (and this might have been said already), in the interest of keeping the > CFC black-boxed... the datasource name should be passed in (as opposed to > referencing the application scope from within the CFC). > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314250 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How to avoid "is not of type query" error using CFC?
Rick Faircloth wrote: > Now I know. The cfreturn variable has to match the query name. Well, no. It has to match what you want to return. Sure there are lots of examples where the return does not match the query name because the query is not what is necessarily returned. But if your function is simple and is just returning the query then yes, the return should match the query name. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314248 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: How to avoid "is not of type query" error using CFC?
the return variable has to match whatever it is you want to return. in *this* case, it's the query. let's say you just wanted to return a recordcount... then the return variable wouldn't match the query name. it'd match a variable name: SELECT * FROM foo WHERE bar = 1 for what it's worth, the function above doesn't need the 'howMany' variable. you can simply . just trying to illustrate the use of variable names for you. also (and this might have been said already), in the interest of keeping the CFC black-boxed... the datasource name should be passed in (as opposed to referencing the application scope from within the CFC). On Wed, Oct 22, 2008 at 9:07 AM, Rick Faircloth <[EMAIL PROTECTED]>wrote: > but, but, but... I thought I saw CFC examples where the cfreturn variable > didn't match the query name. (It didn't make much sense, but then, again, > not a lot of the CFC "stuff" does, right now) > > The change made it work, however. > > Now I know. The cfreturn variable has to match the query name. > > Live and learn... > > Rick > > Charlie Griefer wrote: > > the problem isn't the empty query. an empty query is still a query. the > > problem is you're returning "featured_products" but your query is named > > "get_featured_products". you're returning an empty variable. > > change this line: > > > > > > > > to: > > > > > > > > then change your to return get_featured_products. > > > > On Wed, Oct 22, 2008 at 8:51 AM, Rick Faircloth < > [EMAIL PROTECTED]>wrote: > > > > > > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314246 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How can this CFC be improved?
even if you're a solo developer, creating components that are truly "black-boxed" (e.g. they know nothing of the world outside them), you're creating components that you can potentially reuse yourself. Also, by passing in the information explicitly (rather than referring to outside scopes from within the CFC), you potentially worry less about having to refactor those CFCs. What if in the future, you're not using form variables, but you change to URL variables? The way you have it set up now, you have to make changes to the CFC. if you pass all of the variables in explicitly, it doesn't matter if you're passing form vars, URL vars, session vars, etc. your CFC is still built to work and function properly in any given environment. On Wed, Oct 22, 2008 at 8:39 AM, Rick Faircloth <[EMAIL PROTECTED]>wrote: > I think I'm beginning to understand your reasoning. > It's just taking some time for me to get to the "best practices" of CFC > usage. > Trying to get "anything" to work at first keeps my projects moving, while > beginning to employ different coding techniques. I'm basically trying to > learn by writing code for projects that are going live with these updates > as soon as I can get them working...too busy for much practice. > > Also, I'm a solo developer and never plan to code while working for anyone > else..so as far as sharing code or compensation, it doesn't matter. My > client's > don't care, as long as the correct data shows up on their pages. > > But I am trying to figure out the best way to do all of this. > > Thanks, > > Rick > > Dawson, Michael wrote: > > Technically, they both will work. > > > > However, what if you have a different process of calling the same > > function that doesn't use the form scope? > > > > What if you want to call the same method as a web service? > > > > Your current system will fail at that time. > > > > > > Of course, if you fully control your code and no one else will ever use > > it, then do what you think works best for you. > > > > I have some code that might not pass the approval of several people, but > > it works for me and I can understand it. > > > > If your code is not being compared to others, nor are you being judged > > as part of your compensation, it really doesn't matter. > > > > However, at some point, you will find that following these accepted > > principals will become beneficial. That is when it "clicks" and you see > > the light. > > > > > > > > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314239 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How to avoid "is not of type query" error using CFC?
but, but, but... I thought I saw CFC examples where the cfreturn variable didn't match the query name. (It didn't make much sense, but then, again, not a lot of the CFC "stuff" does, right now) The change made it work, however. Now I know. The cfreturn variable has to match the query name. Live and learn... Rick Charlie Griefer wrote: > the problem isn't the empty query. an empty query is still a query. the > problem is you're returning "featured_products" but your query is named > "get_featured_products". you're returning an empty variable. > change this line: > > > > to: > > > > then change your to return get_featured_products. > > On Wed, Oct 22, 2008 at 8:51 AM, Rick Faircloth <[EMAIL PROTECTED]>wrote: > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314245 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How can this CFC be improved?
> No pain no gain though, right? As long as whatever is causing the pain doesn't kill you! :o) Rick > Using CFCs as function collections like you are doing is the easy part. > Wait till you start creating a true OO backend. I'm working on my first > right now and I thought I was really good at CFCs until I started > this... No pain no gain though, right? > > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314244 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: How can this CFC be improved?
Gotcha... thanks. Charlie Griefer wrote: > even if you're a solo developer, creating components that are truly > "black-boxed" (e.g. they know nothing of the world outside them), you're > creating components that you can potentially reuse yourself. Also, by > passing in the information explicitly (rather than referring to outside > scopes from within the CFC), you potentially worry less about having to > refactor those CFCs. What if in the future, you're not using form > variables, but you change to URL variables? The way you have it set up now, > you have to make changes to the CFC. if you pass all of the variables in > explicitly, it doesn't matter if you're passing form vars, URL vars, session > vars, etc. your CFC is still built to work and function properly in any > given environment. > > On Wed, Oct 22, 2008 at 8:39 AM, Rick Faircloth <[EMAIL PROTECTED]>wrote: > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314243 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How to avoid "is not of type query" error using CFC?
AFter the query do this... That should fix the problem. Rick Faircloth wrote: > I'm running a query to get "featured products". > > For the call, I'm using: > > method ="select_featured_products" >returnVariable="featured_products"/> > > and the cffunction is: > > displayname="select_featured_products" > hint ="Selects Featured Products" > access ="remote" > output ="false" > returntype="query"> > > > > datasource="#application.dsn#"> > > select* > from products > wherefeatured=1 > > > > > > > > The problem I'm running into happens if there are no featured products > and the query is empty. Then I get this error from CF: > > "The value returned from the select_featured_products function is not of > type query." > > How should I modify this CFC (or the call) to work with or without query > values? > > Thanks, > > Rick > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314241 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: How can this CFC be improved?
Right!. Your call (if you are using the form scope) would look like this: object.update_product(argumentCollection=form); or object.update_product(duplicate(form)); Same thing if you are looking at something in the session: object.update_product(argumentCollection=session.key); Rick Faircloth wrote: > Thanks for the feedback, Jake. > > All that "reassigning" of variables is a lot more typing. (But, can I > get around > reassigning each form variable individually by using the > "argumentCollection" > attribute when calling the method?) > > I think I see what you're saying, however. > > By "translating" the type of variable coming in to the method into the > argument scope, > then any type of variable can be fed into the method...session, url, > form, etc.,... making > the method more flexible. > > Right? > > Thanks for the re-write, too! That helps me understand how things need > to change. > > Jake Churchill wrote: > >> I generally make my CFCs as generic as possible. You are updating a >> product and looking in the form scope for everything. It'll work, >> sure. But, what if in the future you get an entire cart. Then you >> won't be looking in the form scope, you'll be looking at something in >> the session or database. In that case, you'll want to be able to loop >> over something and pass stuff into the function which would be very >> tricky if the function is stuck in the form scope. Also, there's no >> reason to copy the arguments over to variables. Variables would be used >> more if you are actually instantiating a CFC as an object. I assume you >> are not because if you did that, you'd probably pass an object into the >> update product. >> >> Here's a way I'd re-write your function to make it more abstract: >> >> > = "Update specified product" output = "false"> >> >> >> > default=""> >> > default=""> >> >> >> > default=""> >> >> >> >> >> updateproducts >> setname = > value="#arguments.name#">, >> description = > value="#arguments.description#">, >> regular_price = > value="#arguments.regular_price#" scale="2">, >> featured = > value="#arguments.featured#">, >> special = > value="#arguments.special#">, >> special_price = > value="#arguments.special_price#" scale="2">, >> photo_150 = > value="#arguments.photo_150#">, >> photo_400 = > value="#arguments.photo_400#"> >> whereproduct_id = "#arguments.product_id#" >> >> >> >> >> -Jake Churchill >> >> Rick Faircloth wrote: >> >> >>> Hi, all... still trying to get a handle on using CFC's. >>> >>> Here's an update method I wrote and I'd like to know >>> what can be changed to make it better. Such as, >>> why not use the form scope in the query? And, why >>> not just use the application scope for the dsn, instead >>> of converting it to the variables scope? >>> >>> If components have access to the url, form, session, and >>> application scopes, etc., why not use them in the component? >>> What's the benefit of converting them? >>> >>> >> displayname="update_product" >>> hint ="Update specified product" >>> output ="false"> >>> >>> >>> >>> >>> >>> >>> updateproducts >>> >>> set name =>> cfsqltype = "cf_sql_varchar"value = "#form.name#">, >>>description=>> cfsqltype = "cf_sql_varchar"value = "#form.description#">, >>>regular_price=>> cfsqltype = "cf_sql_decimal"value = "#form.regular_price#" scale >>> = "2">, >&g
Re: How to avoid "is not of type query" error using CFC?
the problem isn't the empty query. an empty query is still a query. the problem is you're returning "featured_products" but your query is named "get_featured_products". you're returning an empty variable. change this line: to: then change your to return get_featured_products. On Wed, Oct 22, 2008 at 8:51 AM, Rick Faircloth <[EMAIL PROTECTED]>wrote: > I'm running a query to get "featured products". > > For the call, I'm using: > >method ="select_featured_products" > returnVariable="featured_products"/> > > and the cffunction is: > > displayname="select_featured_products" >hint ="Selects Featured Products" >access ="remote" >output ="false" >returntype="query"> > > > > datasource="#application.dsn#"> > >select* >from products >wherefeatured=1 > > > > > > > > The problem I'm running into happens if there are no featured products > and the query is empty. Then I get this error from CF: > > "The value returned from the select_featured_products function is not of > type query." > > How should I modify this CFC (or the call) to work with or without query > values? > > Thanks, > > Rick > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314242 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4