RE: CFCs and UDFs
Yup - that's pretty much what I do as well. love the type checking. ;^) Jim Davis -Original Message- From: Barney Boisvert [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 7:16 PM To: CF-Talk Subject: RE: CFCs and UDFs I knew you could use CFSCRIPT bodies, but I didn't know you could use entire functions. Though without being able to set their access parameter, it's fairly insignificant. Personally, unless I need CFQUERY or HTML output, I write everthing in CFSCRIPT. Just much cleaner, IMHO. CFCs are about the only exception, because of the access control and type checking. cheers, barneyb -Original Message- From: Jim Davis [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 3:58 PM To: CF-Talk Subject: RE: CFCs and UDFs Yeah - what he said. ;^) (I was halfway through the same message. when Ray's came in.) Also you can have CFScript blocks inside a tag-based function - so even if you do need to apply security you can usually convert even complex functions pretty easily (leave the body as script and just convert the arguments and return basically). Jim Davis _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: CFCs and UDFs
I knew you could use CFSCRIPT bodies, but I didn't know you could use entire functions. Though without being able to set their access parameter, it's fairly insignificant. Personally, unless I need CFQUERY or HTML output, I write everthing in CFSCRIPT. Just much cleaner, IMHO. CFCs are about the only exception, because of the access control and type checking. cheers, barneyb -Original Message- From: Jim Davis [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 3:58 PM To: CF-Talk Subject: RE: CFCs and UDFs Yeah - what he said. ;^) (I was halfway through the same message. when Ray's came in.) Also you can have CFScript blocks inside a tag-based function - so even if you do need to apply security you can usually convert even complex functions pretty easily (leave the body as script and just convert the arguments and return basically). Jim Davis [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: CFCs and UDFs
Yeah - what he said. ;^) (I was halfway through the same message. when Ray's came in.) Also you can have CFScript blocks inside a tag-based function - so even if you do need to apply security you can usually convert even complex functions pretty easily (leave the body as script and just convert the arguments and return basically). Jim Davis -Original Message- From: Raymond Camden [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 6:27 PM To: CF-Talk Subject: RE: CFCs and UDFs Eh? You _can_ have script based methods in a CFC. You just can't assign security to it or define return type, etc. alpha.cfc: function hi() { return "hello"; } test.cfm: _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: CFCs and UDFs
Really?!?! That new to 6.1, or been there since the get-go? now all we need is a full declaration syntax: public String hi(String name="world") { return "hello, #name#"; } I can certainly forgo the permissions stuff, and even metadata for the cfcbrowser, but access and return type are important. Sure be nice to have typed parameters in script-based functions, even without 'defaultability'. Seems like it wouldn't be that hard to do from a compilation standpoint, though the lexer would have to be a little more sophisticated (but that's probably generated anyway). -Original Message- From: Raymond Camden [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 3:27 PM To: CF-Talk Subject: RE: CFCs and UDFs Eh? You _can_ have script based methods in a CFC. You just can't assign security to it or define return type, etc. alpha.cfc: function hi() { return "hello"; } test.cfm: [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: CFCs and UDFs
Eh? You _can_ have script based methods in a CFC. You just can't assign security to it or define return type, etc. alpha.cfc: function hi() { return "hello"; } test.cfm: [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: CFCs and UDFs
Thank Barney So it looks like some CFSCRIPT based UDFs may be a bit more of a challenge than the simple example I provided (as we all know we can just use ReFindNoCase for that one). Oh the fun world of CFCs ;-) - Original Message - From: Barney Boisvert To: CF-Talk Sent: Thursday, October 23, 2003 3:19 PM Subject: RE: CFCs and UDFs You can't have CFSCRIPT based functions in a CFC. They have to be tag based. This is what you need: -Original Message- From: Bryan Stevenson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 3:05 PM To: CF-Talk Subject: Re: CFCs and UDFs Thanks Barney...but HUH!!! ;-) Is this what you mean (the cfscript having been the original UDF)?? function IsAlphanumeric(str) { if (ReFindNoCase("[^a-z0-9}", str) eq 0) return true; else return false; } Thanks [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: CFCs and UDFs
You can't have CFSCRIPT based functions in a CFC. They have to be tag based. This is what you need: -Original Message- From: Bryan Stevenson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 3:05 PM To: CF-Talk Subject: Re: CFCs and UDFs Thanks Barney...but HUH!!! ;-) Is this what you mean (the cfscript having been the original UDF)?? function IsAlphanumeric(str) { if (ReFindNoCase("[^a-z0-9}", str) eq 0) return true; else return false; } Thanks [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: CFCs and UDFs
Thanks Barney...but HUH!!! ;-) Is this what you mean (the cfscript having been the original UDF)?? function IsAlphanumeric(str) { if (ReFindNoCase("[^a-z0-9}", str) eq 0) return true; else return false; } Thanks - Original Message - From: Barney Boisvert To: CF-Talk Sent: Thursday, October 23, 2003 2:48 PM Subject: RE: CFCs and UDFs UDF: CFC: To call them you do this: UDF: CFC: If you CFC is in the same directory as your calling code, you only need the root of the filename (not the extension). If it's in a different directory, you'll need the full path. -Original Message- From: Bryan Stevenson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 2:32 PM To: CF-Talk Subject: Re: CFCs and UDFs Thanks guysI figured as much ;-) So how would I go about creating a CFC from an exisitng UDF (like the many found on CFLIB)? Thanks - Original Message - From: Barney Boisvert To: CF-Talk Sent: Thursday, October 23, 2003 2:07 PM Subject: RE: CFCs and UDFs You shouldn't need to. If you need a utility function, it should be a method of the CFC you're in. CFCs should stand on their own as much as possible, so they don't need any external resources (other than method arguments) to function. That's not always possible, but it usually is. If you really have a function you need to use, and it doesn't make sense to put the function in the CFC directly, put it in another CFC that you don't instantiate, you just call methods on statically. In other words, CFINVOKE with the name of the CFC, not CFOBJECT or createObject() and then a method call on the object. You can then call that method from your CFC as if it where a UDF, and you don't have to include it anywhere first. barneyb -Original Message- From: Bryan Stevenson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 1:57 PM To: CF-Talk Subject: CFCs and UDFs Hey All, Can a UDF be used inside a CFC is the UDF is included in the template that calls the CFC? or the UDF is included via Application.cfm? From what I've seen it cannot...but mabye my info is off ;-) TIA Cheers Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. t. 250.920.8830 e. [EMAIL PROTECTED] - Macromedia Associate Partner www.macromedia.com - Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: CFCs and UDFs
UDF: CFC: To call them you do this: UDF: CFC: If you CFC is in the same directory as your calling code, you only need the root of the filename (not the extension). If it's in a different directory, you'll need the full path. -Original Message- From: Bryan Stevenson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 2:32 PM To: CF-Talk Subject: Re: CFCs and UDFs Thanks guysI figured as much ;-) So how would I go about creating a CFC from an exisitng UDF (like the many found on CFLIB)? Thanks - Original Message - From: Barney Boisvert To: CF-Talk Sent: Thursday, October 23, 2003 2:07 PM Subject: RE: CFCs and UDFs You shouldn't need to. If you need a utility function, it should be a method of the CFC you're in. CFCs should stand on their own as much as possible, so they don't need any external resources (other than method arguments) to function. That's not always possible, but it usually is. If you really have a function you need to use, and it doesn't make sense to put the function in the CFC directly, put it in another CFC that you don't instantiate, you just call methods on statically. In other words, CFINVOKE with the name of the CFC, not CFOBJECT or createObject() and then a method call on the object. You can then call that method from your CFC as if it where a UDF, and you don't have to include it anywhere first. barneyb -Original Message- From: Bryan Stevenson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 1:57 PM To: CF-Talk Subject: CFCs and UDFs Hey All, Can a UDF be used inside a CFC is the UDF is included in the template that calls the CFC? or the UDF is included via Application.cfm? From what I've seen it cannot...but mabye my info is off ;-) TIA Cheers Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. t. 250.920.8830 e. [EMAIL PROTECTED] - Macromedia Associate Partner www.macromedia.com - Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: CFCs and UDFs
Thanks guysI figured as much ;-) So how would I go about creating a CFC from an exisitng UDF (like the many found on CFLIB)? Thanks - Original Message - From: Barney Boisvert To: CF-Talk Sent: Thursday, October 23, 2003 2:07 PM Subject: RE: CFCs and UDFs You shouldn't need to. If you need a utility function, it should be a method of the CFC you're in. CFCs should stand on their own as much as possible, so they don't need any external resources (other than method arguments) to function. That's not always possible, but it usually is. If you really have a function you need to use, and it doesn't make sense to put the function in the CFC directly, put it in another CFC that you don't instantiate, you just call methods on statically. In other words, CFINVOKE with the name of the CFC, not CFOBJECT or createObject() and then a method call on the object. You can then call that method from your CFC as if it where a UDF, and you don't have to include it anywhere first. barneyb -Original Message- From: Bryan Stevenson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 1:57 PM To: CF-Talk Subject: CFCs and UDFs Hey All, Can a UDF be used inside a CFC is the UDF is included in the template that calls the CFC? or the UDF is included via Application.cfm? From what I've seen it cannot...but mabye my info is off ;-) TIA Cheers Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. t. 250.920.8830 e. [EMAIL PROTECTED] - Macromedia Associate Partner www.macromedia.com - Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: CFCs and UDFs
I agree with this post, but there is another not too recommended way of getting that UDF, place it in say session scope and then you can access it from within your CFC TK - Original Message - From: Barney Boisvert To: CF-Talk Sent: Thursday, October 23, 2003 5:07 PM Subject: RE: CFCs and UDFs You shouldn't need to. If you need a utility function, it should be a method of the CFC you're in. CFCs should stand on their own as much as possible, so they don't need any external resources (other than method arguments) to function. That's not always possible, but it usually is. If you really have a function you need to use, and it doesn't make sense to put the function in the CFC directly, put it in another CFC that you don't instantiate, you just call methods on statically. In other words, CFINVOKE with the name of the CFC, not CFOBJECT or createObject() and then a method call on the object. You can then call that method from your CFC as if it where a UDF, and you don't have to include it anywhere first. barneyb -Original Message- From: Bryan Stevenson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 1:57 PM To: CF-Talk Subject: CFCs and UDFs Hey All, Can a UDF be used inside a CFC is the UDF is included in the template that calls the CFC? or the UDF is included via Application.cfm? From what I've seen it cannot...but mabye my info is off ;-) TIA Cheers Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. t. 250.920.8830 e. [EMAIL PROTECTED] - Macromedia Associate Partner www.macromedia.com - Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: CFCs and UDFs
If it can be, it shouldn't be. But, I'm pretty sure it can't. Adam Wayne Lehman Web Systems Developer Johns Hopkins Bloomberg School of Public Health Distance Education Division -Original Message- From: Bryan Stevenson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 4:57 PM To: CF-Talk Subject: CFCs and UDFs Hey All, Can a UDF be used inside a CFC is the UDF is included in the template that calls the CFC? or the UDF is included via Application.cfm? >From what I've seen it cannot...but mabye my info is off ;-) TIA Cheers Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. t. 250.920.8830 e. [EMAIL PROTECTED] - Macromedia Associate Partner www.macromedia.com - Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: CFCs and UDFs
You shouldn't need to. If you need a utility function, it should be a method of the CFC you're in. CFCs should stand on their own as much as possible, so they don't need any external resources (other than method arguments) to function. That's not always possible, but it usually is. If you really have a function you need to use, and it doesn't make sense to put the function in the CFC directly, put it in another CFC that you don't instantiate, you just call methods on statically. In other words, CFINVOKE with the name of the CFC, not CFOBJECT or createObject() and then a method call on the object. You can then call that method from your CFC as if it where a UDF, and you don't have to include it anywhere first. barneyb -Original Message- From: Bryan Stevenson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 23, 2003 1:57 PM To: CF-Talk Subject: CFCs and UDFs Hey All, Can a UDF be used inside a CFC is the UDF is included in the template that calls the CFC? or the UDF is included via Application.cfm? From what I've seen it cannot...but mabye my info is off ;-) TIA Cheers Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. t. 250.920.8830 e. [EMAIL PROTECTED] - Macromedia Associate Partner www.macromedia.com - Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]