Re: CFC Newbie

2010-03-22 Thread Dave Watts

 I'm trying to get out of MX non CFC world. I've now working with CF8 and
 want to start converting some of my things to use CFC's. Specifically how I
 can use forms to interact with CFC's to add/edit/delete data. I've read a
 few tutorials from adobe about them and what I've seen on a few blogs but
 none address using cfc's in form to do the data add/editing.. Anyone have
 links to tutorials/readme's ? examples?

There are some examples in the ACFD 8 courseware available here:

http://www.adobe.com/education/instruction/teach/cfcurriculum.html

Basically, in the simplest case, you write functions within CFCs to
accept your field values, and have those functions run the appropriate
SQL. You invoke those functions from your action page, instead of
having the SQL embedded in-place. Note that this is only the simplest
case; many developers use CFCs to represent individual records (beans
or value objects), and use other CFCs to manipulate those beans by
reading from and writing to the database.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:331956
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: CFC Newbie

2010-03-22 Thread Tony Bentley

ask and you shall be enlightened:

http://www.bennadel.com/blog/726-ColdFusion-Application-cfc-Tutorial-And-Application-cfc-Reference.htm
 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332007
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: CFC Newbie

2010-03-22 Thread Dave Watts

 ask and you shall be enlightened:

 http://www.bennadel.com/blog/726-ColdFusion-Application-cfc-Tutorial-And-Application-cfc-Reference.htm

While that's useful information to be sure, it doesn't address the
original poster's question, which is about CFC use in general.
Application.cfc is quite a bit different from other CFCs in how it's
used - you don't explicitly instantiate it, for example.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332008
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: CFC Newbie

2010-03-22 Thread Ben Forta

These are old, but may answer the question:

http://www.adobe.com/devnet/coldfusion/articles/intro_cfcs.html
http://www.adobe.com/devnet/coldfusion/extreme/bforta_cfc.html

--- Ben


-Original Message-
From: Dave Watts [mailto:dwa...@figleaf.com] 
Sent: Monday, March 22, 2010 3:44 PM
To: cf-talk
Subject: Re: CFC Newbie


 ask and you shall be enlightened:


http://www.bennadel.com/blog/726-ColdFusion-Application-cfc-Tutorial-And-App
lication-cfc-Reference.htm

While that's useful information to be sure, it doesn't address the
original poster's question, which is about CFC use in general.
Application.cfc is quite a bit different from other CFCs in how it's
used - you don't explicitly instantiate it, for example.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332009
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: CFC Newbie

2010-03-22 Thread Scott Raley

Yep read those first Ben!

-Original Message-
From: Ben Forta [mailto:b...@forta.com] 
Sent: Monday, March 22, 2010 3:49 PM
To: cf-talk
Subject: RE: CFC Newbie


These are old, but may answer the question:

http://www.adobe.com/devnet/coldfusion/articles/intro_cfcs.html
http://www.adobe.com/devnet/coldfusion/extreme/bforta_cfc.html

--- Ben


-Original Message-
From: Dave Watts [mailto:dwa...@figleaf.com] 
Sent: Monday, March 22, 2010 3:44 PM
To: cf-talk
Subject: Re: CFC Newbie


 ask and you shall be enlightened:


http://www.bennadel.com/blog/726-ColdFusion-Application-cfc-Tutorial-And-App
lication-cfc-Reference.htm

While that's useful information to be sure, it doesn't address the
original poster's question, which is about CFC use in general.
Application.cfc is quite a bit different from other CFCs in how it's
used - you don't explicitly instantiate it, for example.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.





~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332012
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: CFC Newbie Question: Encapsulation

2006-02-16 Thread James Holmes
Yes, encapsulation is an important part of OO and yes many people don't care.

If you want to maintain the encapsulation, don't set thigns in the
THIS scope - use a setter method to set them in the VARIABLES scope
(and a getter method to get them out again):

cfscript
 newUser = createobject(component, user);
 newUser.setname(john);
/cfscript

On 2/17/06, Aaron Roberson [EMAIL PROTECTED] wrote:
 Friends,

 I am learning Java and CFC development in ColdFusion at the same time.
 I keep going back and forth between the two because they complement
 each other so well. Anyways, my question is not in regards to the
 specifics of the language, but with OOP design patterns and
 encapsulation.

 HERE IT GOES:

 In my Java book it says that if a method is public, a data filed could
 be assigned a value directly, BUT doing so violates an important
 principle of object-oriented programming -- that of data hiding using
 encapsulation.

 However, I have seen alot of CF developers write code that directly
 assigns values to data fields in CFC's like the following:

 CALLING PAGE

 cfscript
 newUser = createobject(component, user);
 newUser.name = john
 newuser.setname();
 /cfscript

 COMPONENT

 cfcomponent hint=manages users

 cfscript
 init();
 /cfscript

 cffunction name=init access=public output=no hint=psuedo constructor
 cfset this.userID = #createUUID()#
 cfreturn this
 /cffunction

 cffunction name=setuser access=public output=no hint=sets user info
 cfargument name=userID type=UUID required=yes
 cfset arguments.userID = this.userID
 !--- processing code ---
 /cffunction

 /cfcomponent

 

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232658
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: CFC Newbie Question: Encapsulation

2006-02-16 Thread Aaron Roberson
What about the constructor function? Shouldn't I set the properties in
the THIS scope when initializing a component?

Also, what is the difference between the variables scope and the
arguments scope withing a method? I have seen properties defined using
the cfargument tag referenced in the method using both the arguments
scope and the variables scope.

-Aaron

On 2/16/06, James Holmes [EMAIL PROTECTED] wrote:
 Yes, encapsulation is an important part of OO and yes many people don't care.

 If you want to maintain the encapsulation, don't set thigns in the
 THIS scope - use a setter method to set them in the VARIABLES scope
 (and a getter method to get them out again):

 cfscript
  newUser = createobject(component, user);
  newUser.setname(john);
 /cfscript

 On 2/17/06, Aaron Roberson [EMAIL PROTECTED] wrote:
  Friends,
 
  I am learning Java and CFC development in ColdFusion at the same time.
  I keep going back and forth between the two because they complement
  each other so well. Anyways, my question is not in regards to the
  specifics of the language, but with OOP design patterns and
  encapsulation.
 
  HERE IT GOES:
 
  In my Java book it says that if a method is public, a data filed could
  be assigned a value directly, BUT doing so violates an important
  principle of object-oriented programming -- that of data hiding using
  encapsulation.
 
  However, I have seen alot of CF developers write code that directly
  assigns values to data fields in CFC's like the following:
 
  CALLING PAGE
 
  cfscript
  newUser = createobject(component, user);
  newUser.name = john
  newuser.setname();
  /cfscript
 
  COMPONENT
 
  cfcomponent hint=manages users
 
  cfscript
  init();
  /cfscript
 
  cffunction name=init access=public output=no hint=psuedo 
  constructor
  cfset this.userID = #createUUID()#
  cfreturn this
  /cffunction
 
  cffunction name=setuser access=public output=no hint=sets user 
  info
  cfargument name=userID type=UUID required=yes
  cfset arguments.userID = this.userID
  !--- processing code ---
  /cffunction
 
  /cfcomponent
 
 

 

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232661
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: CFC Newbie Question: Encapsulation

2006-02-16 Thread James Holmes
The only use for THIS in an OO-based component is to return THIS at
the end of the constructor. That returns the entire component for use
as an instance.

The properties will be in the VARIABLES scope; they can be used via
getter and setter methods. This is where the ARGUMENTS scope comes in
- the setter methods take an argument, check it for validity and then
set a value in the VARIABLES scope. The VARIABLES scope remains
between method calls, acting as storage within the instance.

On 2/17/06, Aaron Roberson [EMAIL PROTECTED] wrote:
 What about the constructor function? Shouldn't I set the properties in
 the THIS scope when initializing a component?

 Also, what is the difference between the variables scope and the
 arguments scope withing a method? I have seen properties defined using
 the cfargument tag referenced in the method using both the arguments
 scope and the variables scope.

--
CFAJAX docs and other useful articles:
http://jr-holmes.coldfusionjournal.com/

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232664
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: CFC Newbie Question: Encapsulation

2006-02-16 Thread Aaron Roberson
 The only use for THIS in an OO-based component is to return THIS at
 the end of the constructor. That returns the entire component for use
 as an instance.

In Java, the constructer is for providing arguments with default
values. These default values can be the ones that are automaticly
assigned to each corresponding data type, or if you create a
constructer method it will be the values you specify.

 The properties will be in the VARIABLES scope; they can be used via
 getter and setter methods. This is where the ARGUMENTS scope comes in
 - the setter methods take an argument, check it for validity and then
 set a value in the VARIABLES scope. The VARIABLES scope remains
 between method calls, acting as storage within the instance.

So within my setter method I would do something like the following:

cfargument name=this.name type=string default=
cfset variables.name = this.name

The intention would be to make the name property persist across
method calls? I don't think I really understand what that means. I am
thinking in terms of sessions and applications but I don't think their
related. If I assign something to the session scope, the variable
remains the same throught the entire session unless it is changed by
another assignment. If an object is instantiated, all properties in
the variable scope will remain the same on the calling page, but what
about on other pages? What is the life cycle of an instance?

Sorry for all the questions... I hope someone else relieves you from
doing all the work of saving me from despair...

Thanks so much,
Aaron

On 2/16/06, James Holmes [EMAIL PROTECTED] wrote:
 The only use for THIS in an OO-based component is to return THIS at
 the end of the constructor. That returns the entire component for use
 as an instance.

 The properties will be in the VARIABLES scope; they can be used via
 getter and setter methods. This is where the ARGUMENTS scope comes in
 - the setter methods take an argument, check it for validity and then
 set a value in the VARIABLES scope. The VARIABLES scope remains
 between method calls, acting as storage within the instance.

 On 2/17/06, Aaron Roberson [EMAIL PROTECTED] wrote:
  What about the constructor function? Shouldn't I set the properties in
  the THIS scope when initializing a component?
 
  Also, what is the difference between the variables scope and the
  arguments scope withing a method? I have seen properties defined using
  the cfargument tag referenced in the method using both the arguments
  scope and the variables scope.

 --
 CFAJAX docs and other useful articles:
 http://jr-holmes.coldfusionjournal.com/

 

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232668
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: CFC Newbie Question: Encapsulation

2006-02-16 Thread James Holmes
No, for the moment, forget THIS.

 cfargument name=this.name type=string default=
 cfset variables.name = this.name

should be

cfargument name=name type=string default=
cfset VARIABLES.name = ARGUMENTS.name

The life cycle of the instance depends on where you put it.
Instantiate it in the session scope, it lasts as long as the session.
Similar for the application scope.

The use of THIS is to make this bit work:

cfset myObjectInstance = CreateObject(component,someCFC).init()

Inside that, the init() method returns THIS

cffunction name=init
  !-- set defaults, whatever ---
  cfreturn THIS
/cffunction

That's the only time you need to use THIS in the whole component.

On 2/17/06, Aaron Roberson [EMAIL PROTECTED] wrote:
  The only use for THIS in an OO-based component is to return THIS at
  the end of the constructor. That returns the entire component for use
  as an instance.

 In Java, the constructer is for providing arguments with default
 values. These default values can be the ones that are automaticly
 assigned to each corresponding data type, or if you create a
 constructer method it will be the values you specify.

  The properties will be in the VARIABLES scope; they can be used via
  getter and setter methods. This is where the ARGUMENTS scope comes in
  - the setter methods take an argument, check it for validity and then
  set a value in the VARIABLES scope. The VARIABLES scope remains
  between method calls, acting as storage within the instance.

 So within my setter method I would do something like the following:

 cfargument name=this.name type=string default=
 cfset variables.name = this.name

 The intention would be to make the name property persist across
 method calls? I don't think I really understand what that means. I am
 thinking in terms of sessions and applications but I don't think their
 related. If I assign something to the session scope, the variable
 remains the same throught the entire session unless it is changed by
 another assignment. If an object is instantiated, all properties in
 the variable scope will remain the same on the calling page, but what
 about on other pages? What is the life cycle of an instance?

 Sorry for all the questions... I hope someone else relieves you from
 doing all the work of saving me from despair...

 Thanks so much,
 Aaron

 On 2/16/06, James Holmes [EMAIL PROTECTED] wrote:
  The only use for THIS in an OO-based component is to return THIS at
  the end of the constructor. That returns the entire component for use
  as an instance.
 
  The properties will be in the VARIABLES scope; they can be used via
  getter and setter methods. This is where the ARGUMENTS scope comes in
  - the setter methods take an argument, check it for validity and then
  set a value in the VARIABLES scope. The VARIABLES scope remains
  between method calls, acting as storage within the instance.
 
  On 2/17/06, Aaron Roberson [EMAIL PROTECTED] wrote:
   What about the constructor function? Shouldn't I set the properties in
   the THIS scope when initializing a component?
  
   Also, what is the difference between the variables scope and the
   arguments scope withing a method? I have seen properties defined using
   the cfargument tag referenced in the method using both the arguments
   scope and the variables scope.
 
  --
  CFAJAX docs and other useful articles:
  http://jr-holmes.coldfusionjournal.com/
 
 

 

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232671
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: CFC Newbie Question: Encapsulation

2006-02-16 Thread Aaron Roberson
James,

I am going to keep all of these threads, print them out, and go over
them multiple times until I begin to grasp it all. I guess I won't be
learning CFAJAX until I get CFC's down, which is proving to be quite a
task and very lengthy process.

Thanks again and again!

-Aaron

To instantiate or not to instantiate, that is the question. - 21st
Century Shakespeare

On 2/16/06, James Holmes [EMAIL PROTECTED] wrote:
 No, for the moment, forget THIS.

  cfargument name=this.name type=string default=
  cfset variables.name = this.name

 should be

 cfargument name=name type=string default=
 cfset VARIABLES.name = ARGUMENTS.name

 The life cycle of the instance depends on where you put it.
 Instantiate it in the session scope, it lasts as long as the session.
 Similar for the application scope.

 The use of THIS is to make this bit work:

 cfset myObjectInstance = CreateObject(component,someCFC).init()

 Inside that, the init() method returns THIS

 cffunction name=init
   !-- set defaults, whatever ---
   cfreturn THIS
 /cffunction

 That's the only time you need to use THIS in the whole component.

 On 2/17/06, Aaron Roberson [EMAIL PROTECTED] wrote:
   The only use for THIS in an OO-based component is to return THIS at
   the end of the constructor. That returns the entire component for use
   as an instance.
 
  In Java, the constructer is for providing arguments with default
  values. These default values can be the ones that are automaticly
  assigned to each corresponding data type, or if you create a
  constructer method it will be the values you specify.
 
   The properties will be in the VARIABLES scope; they can be used via
   getter and setter methods. This is where the ARGUMENTS scope comes in
   - the setter methods take an argument, check it for validity and then
   set a value in the VARIABLES scope. The VARIABLES scope remains
   between method calls, acting as storage within the instance.
 
  So within my setter method I would do something like the following:
 
  cfargument name=this.name type=string default=
  cfset variables.name = this.name
 
  The intention would be to make the name property persist across
  method calls? I don't think I really understand what that means. I am
  thinking in terms of sessions and applications but I don't think their
  related. If I assign something to the session scope, the variable
  remains the same throught the entire session unless it is changed by
  another assignment. If an object is instantiated, all properties in
  the variable scope will remain the same on the calling page, but what
  about on other pages? What is the life cycle of an instance?
 
  Sorry for all the questions... I hope someone else relieves you from
  doing all the work of saving me from despair...
 
  Thanks so much,
  Aaron
 
  On 2/16/06, James Holmes [EMAIL PROTECTED] wrote:
   The only use for THIS in an OO-based component is to return THIS at
   the end of the constructor. That returns the entire component for use
   as an instance.
  
   The properties will be in the VARIABLES scope; they can be used via
   getter and setter methods. This is where the ARGUMENTS scope comes in
   - the setter methods take an argument, check it for validity and then
   set a value in the VARIABLES scope. The VARIABLES scope remains
   between method calls, acting as storage within the instance.
  
   On 2/17/06, Aaron Roberson [EMAIL PROTECTED] wrote:
What about the constructor function? Shouldn't I set the properties in
the THIS scope when initializing a component?
   
Also, what is the difference between the variables scope and the
arguments scope withing a method? I have seen properties defined using
the cfargument tag referenced in the method using both the arguments
scope and the variables scope.
  
   --
   CFAJAX docs and other useful articles:
   http://jr-holmes.coldfusionjournal.com/
  
  
 
 

 

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232674
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: CFC Newbie Question: Encapsulation

2006-02-16 Thread Rick Root
Aaron Roberson wrote:
 
 I am going to keep all of these threads, print them out, and go over
 them multiple times until I begin to grasp it all. I guess I won't be
 learning CFAJAX until I get CFC's down, which is proving to be quite a
 task and very lengthy process.

CFCs are wonderful!

If you want to see an example of using the this scope and an init() 
function within a CFC, look at the code in CFFM:

http://www.opensourcecf.com/cffm

In that case, I use an init() to set properties, which is good in the OO 
world (like a constructor in java), but I use the this scope instead of 
the variables scope, so I don't have to write getter and setter methods.

It is a violation of object oriented programming, but I really don't 
care in this case =)

Rick

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232679
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: CFC Newbie Question: Encapsulation

2006-02-16 Thread Aaron Roberson
Thanks Rick, I will surely take a look.

-Aaron

On 2/16/06, Rick Root [EMAIL PROTECTED] wrote:
 Aaron Roberson wrote:
 
  I am going to keep all of these threads, print them out, and go over
  them multiple times until I begin to grasp it all. I guess I won't be
  learning CFAJAX until I get CFC's down, which is proving to be quite a
  task and very lengthy process.

 CFCs are wonderful!

 If you want to see an example of using the this scope and an init()
 function within a CFC, look at the code in CFFM:

 http://www.opensourcecf.com/cffm

 In that case, I use an init() to set properties, which is good in the OO
 world (like a constructor in java), but I use the this scope instead of
 the variables scope, so I don't have to write getter and setter methods.

 It is a violation of object oriented programming, but I really don't
 care in this case =)

 Rick

 

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232680
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: CFC Newbie Question: Encapsulation

2006-02-16 Thread Rick Root
On 2/17/06, Aaron Roberson [EMAIL PROTECTED] wrote:

 In my Java book it says that if a method is public, a data filed could
 be assigned a value directly, BUT doing so violates an important
 principle of object-oriented programming -- that of data hiding using
 encapsulation.

 However, I have seen alot of CF developers write code that directly
 assigns values to data fields in CFC's like the following:


Officially, yes, true object oriented programming does not allow you to 
access variables in an object directly.  You can reference constants 
directly, but never set or retrieve variables.

In the CFC world I don't think there is any such thing as a constant, so 
you're either going to program get/set methods, or you're not.

My preference - for the most part - is not.

In a large development environment, with many developers working on 
difference pieces of a project, it does make sense to do this kind of 
encapsulation, because it protects your variables and allows you to 
control what values they contain.

For example, if you're using the this scope to store an ID variable that 
is an integer, if you ALLOW that variable to be set from the outside 
world (maybe someone elses CFC), then they could easily set it to foo, 
and suddenly something doesn't work the way they expect it to and it 
breaks in YOUR code.

In the world of encapsulation, you control how that variable is set. 
This example only returns false but it could return or log a more 
specific error message.

cfcomponent
cfset variables.id = 0
cffunction name=setID access=public output=false 
returnType=boolean hint=pretend ID must be a non negative 10 digit 
number that starts with 10
cfargument name=id type=numeric required=yes
cfif id neq int(id)
 !--- it's not an integer ---
 cfreturn false
cfelseif id neq abs(id)
 !--- it's a negative number ---
 cfreturn false
cfelseif len(id) neq 10
 !--- it's not 10 digits ---
 cfreturn false
cfelseif left(id,2) neq 10
 !--- it doesn't start with 10 ---
 cfreturn false
cfelse
 cfset variables.id = id
 cfreturn true
/cfif
/cffunction
/cfcomponent


This forces other programmers using your CFC to send proper data to the 
variable, or setting the variable will fail, preventing unknown 
consequences later in the application.

Rick

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232678
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: CFC newbie: trying the calendar API, getting error

2005-01-25 Thread Simeon Bateman
it looks like it is specifically coded to run from the calendar
folder.  Try creating a calendar folder and dropping all the files in
that and running it again.

I dropped the folder that unzipped from the download, into my webroot.
 called /calendar/sample/index.cfm and the whole app came to life.

Good Luck
simeon

On Tue, 25 Jan 2005 12:38:23 -0500, Damien McKenna
[EMAIL PROTECTED] wrote:
 Greetings everyone.
 
 I'm trying out the calendar API
 (http://www.horwith.com/index.cfm?mode=entryentry=C8837FD9-E081-0478-47
 F93823F4029950) and obviously have the directory structure messed up
 somehow as it isn't working.  I've set it up where all of the files are
 under the site root and get this error:
 
 Could not find the ColdFusion Component calendar.cfc.calendar.
 Please check that the given name is correct and that the component
 exists.
 The error occurred in
 C:\Inetpub\wwwroot\secure3_spnvision_com\calendar\sample\Application.cfm
 : line 23
 21 :// set this to the path to your component
 22 :request.useScope.calendarCFCPath =
 calendar.cfc.calendar;
 23 :request.useScope.objCalendar = createObject(component,
 request.useScope.calendarCFCPath);
 24 :request.useScope.objCalendar.init(now(), true);
 25 :request.useScope.objCalendar.setWeekStart(1);
 
 Anyone care to help me set this up?  Thanks.
 
 --
 Damien McKenna - Web Developer - [EMAIL PROTECTED]
 The Limu Company - http://www.thelimucompany.com/ - 407-804-1014
 #include stdjoke.h
 
 

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:191747
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: CFC Newbie Discussion.

2003-06-10 Thread Michael Tangorre
Let me point out the scope bug...

using this scope exposes your data members outside of the cfc. In
addition, the varibales scope is not the default for not providing a scope
within a CFC. There is something known as the unknown scope. This unknown
scope allows data members to be available to functions within the CFC... not
outside of.

this.someVar would be accessible inside and outside of the CFC
someVar would be accessible inside the CFC to the functions only.



- Original Message - 
From: Ian Skinner [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 1:24 PM
Subject: CFC Newbie Discussion.


 I'm experimenting with my first CFC.  I've written these simple example
 files.

 *** test.cfc ***
 cfcomponent displayname=My First CFC hint=A trial CFC
 cfset this.X = 10
 cfset this.Y = 15

 cfset A = 5
 cfset B = 3

 cffunction name=multiplyXY access=public returntype=numeric
 cfset myResult = this.X * this.Y
 cfreturn myResult
 /cffunction

 cffunction name=multiplyAB access=public returntype=numeric
 cfset myResult = A * B
 cfreturn myResult
 /cffunction
 /cfcomponent
 *** end ***

 *** test.cfm ***
 cfobject name=testObj component=test
 cfdump var=#testObj#

 cfset this.X = 12
 cfset this.Y = 24

 cfset A = 21
 cfset B = 32

 cfinvoke component=#testObj# method=multiplyXY returnvariable=joe/
 cfinvoke component=#testObj# method=multiplyAB returnvariable=sam/

 cfinvoke component=test method=multiplyXY returnvariable=joe2/
 cfinvoke component=test method=multiplyAB returnvariable=sam2/

 cfoutput
 #testObj.X# * #testObj.Y# = #joe#br
 #testObj.X# * #testObj.Y# = #testObj.multiplyXY()#br
 #this.X# * #this.Y# = #this.X * this.Y#br
 br
 #sam#br
 #testObj.multiplyAB()#br
 #A * B#br
 br
 #joe2#br
 #sam2#br
 /cfoutput
 *** end ***

 What I would like to discuss is the performance differences between the
 various component methods I've tested here.

 In the CFC code, the X and Y variables are in the this scope and the A
and
 B variables are in the default variable scope.  What are the differences
 between these practices other then the X and Y are available as properties
 of an object (obj.X and obj.Y).

 Then in the CFM code I accessed the component a couple different ways.  I
 first used a cfobject tag to instantiate an instance of the component
as
 a object variable testObj.  I then accessed the methods of that instance
 with a cfinvoke on testObj and directly [testObj.method()].  Finally I
 just accessed the methods of the component directly with cfinvoke.

 I would like to discuss the pros and cons of these different practices and
 when one might be better then another.  Also, I remember reading about
some
 kind of scope bug involving CFC's, but since I wasn't really familiar with
 CFC's at the time, I really didn't understand what I was reading.  What
 would this be about?

 Thank You

 --
 Ian Skinner
 Web Programmer
 BloodSource
 Sacramento, CA

 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: CFC Newbie Discussion.

2003-06-10 Thread Michael Tangorre
In terms of which is the most efficient way of calling a cfcs... I like to
use
CreateObject(objectname,component);

Thinking about CFCs like classes in Java or C++ is natural for me, so I like
to work in that mentality.. like Hal Helms points out.

Keep in mind though, some hosting providers limit the use of this function.
cfinvoke is nice as well...

- Original Message - 
From: Ian Skinner [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 1:24 PM
Subject: CFC Newbie Discussion.


 I'm experimenting with my first CFC.  I've written these simple example
 files.

 *** test.cfc ***
 cfcomponent displayname=My First CFC hint=A trial CFC
 cfset this.X = 10
 cfset this.Y = 15

 cfset A = 5
 cfset B = 3

 cffunction name=multiplyXY access=public returntype=numeric
 cfset myResult = this.X * this.Y
 cfreturn myResult
 /cffunction

 cffunction name=multiplyAB access=public returntype=numeric
 cfset myResult = A * B
 cfreturn myResult
 /cffunction
 /cfcomponent
 *** end ***

 *** test.cfm ***
 cfobject name=testObj component=test
 cfdump var=#testObj#

 cfset this.X = 12
 cfset this.Y = 24

 cfset A = 21
 cfset B = 32

 cfinvoke component=#testObj# method=multiplyXY returnvariable=joe/
 cfinvoke component=#testObj# method=multiplyAB returnvariable=sam/

 cfinvoke component=test method=multiplyXY returnvariable=joe2/
 cfinvoke component=test method=multiplyAB returnvariable=sam2/

 cfoutput
 #testObj.X# * #testObj.Y# = #joe#br
 #testObj.X# * #testObj.Y# = #testObj.multiplyXY()#br
 #this.X# * #this.Y# = #this.X * this.Y#br
 br
 #sam#br
 #testObj.multiplyAB()#br
 #A * B#br
 br
 #joe2#br
 #sam2#br
 /cfoutput
 *** end ***

 What I would like to discuss is the performance differences between the
 various component methods I've tested here.

 In the CFC code, the X and Y variables are in the this scope and the A
and
 B variables are in the default variable scope.  What are the differences
 between these practices other then the X and Y are available as properties
 of an object (obj.X and obj.Y).

 Then in the CFM code I accessed the component a couple different ways.  I
 first used a cfobject tag to instantiate an instance of the component
as
 a object variable testObj.  I then accessed the methods of that instance
 with a cfinvoke on testObj and directly [testObj.method()].  Finally I
 just accessed the methods of the component directly with cfinvoke.

 I would like to discuss the pros and cons of these different practices and
 when one might be better then another.  Also, I remember reading about
some
 kind of scope bug involving CFC's, but since I wasn't really familiar with
 CFC's at the time, I really didn't understand what I was reading.  What
 would this be about?

 Thank You

 --
 Ian Skinner
 Web Programmer
 BloodSource
 Sacramento, CA

 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: CFC Newbie Discussion.

2003-06-10 Thread Michael Tangorre
not unknown... obviosuly its known :-)  known as nothing!
That should read the unnamed scope.

Sorry If I confused matters...


- Original Message - 
From: Michael Tangorre [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 1:32 PM
Subject: Re: CFC Newbie Discussion.


 Let me point out the scope bug...

 using this scope exposes your data members outside of the cfc. In
 addition, the varibales scope is not the default for not providing a scope
 within a CFC. There is something known as the unknown scope. This
unknown
 scope allows data members to be available to functions within the CFC...
not
 outside of.

 this.someVar would be accessible inside and outside of the CFC
 someVar would be accessible inside the CFC to the functions only.



 - Original Message - 
 From: Ian Skinner [EMAIL PROTECTED]
 To: CF-Talk [EMAIL PROTECTED]
 Sent: Tuesday, June 10, 2003 1:24 PM
 Subject: CFC Newbie Discussion.


  I'm experimenting with my first CFC.  I've written these simple example
  files.
 
  *** test.cfc ***
  cfcomponent displayname=My First CFC hint=A trial CFC
  cfset this.X = 10
  cfset this.Y = 15
 
  cfset A = 5
  cfset B = 3
 
  cffunction name=multiplyXY access=public returntype=numeric
  cfset myResult = this.X * this.Y
  cfreturn myResult
  /cffunction
 
  cffunction name=multiplyAB access=public returntype=numeric
  cfset myResult = A * B
  cfreturn myResult
  /cffunction
  /cfcomponent
  *** end ***
 
  *** test.cfm ***
  cfobject name=testObj component=test
  cfdump var=#testObj#
 
  cfset this.X = 12
  cfset this.Y = 24
 
  cfset A = 21
  cfset B = 32
 
  cfinvoke component=#testObj# method=multiplyXY
returnvariable=joe/
  cfinvoke component=#testObj# method=multiplyAB
returnvariable=sam/
 
  cfinvoke component=test method=multiplyXY returnvariable=joe2/
  cfinvoke component=test method=multiplyAB returnvariable=sam2/
 
  cfoutput
  #testObj.X# * #testObj.Y# = #joe#br
  #testObj.X# * #testObj.Y# = #testObj.multiplyXY()#br
  #this.X# * #this.Y# = #this.X * this.Y#br
  br
  #sam#br
  #testObj.multiplyAB()#br
  #A * B#br
  br
  #joe2#br
  #sam2#br
  /cfoutput
  *** end ***
 
  What I would like to discuss is the performance differences between the
  various component methods I've tested here.
 
  In the CFC code, the X and Y variables are in the this scope and the A
 and
  B variables are in the default variable scope.  What are the
differences
  between these practices other then the X and Y are available as
properties
  of an object (obj.X and obj.Y).
 
  Then in the CFM code I accessed the component a couple different ways.
I
  first used a cfobject tag to instantiate an instance of the
component
 as
  a object variable testObj.  I then accessed the methods of that
instance
  with a cfinvoke on testObj and directly [testObj.method()].  Finally I
  just accessed the methods of the component directly with cfinvoke.
 
  I would like to discuss the pros and cons of these different practices
and
  when one might be better then another.  Also, I remember reading about
 some
  kind of scope bug involving CFC's, but since I wasn't really familiar
with
  CFC's at the time, I really didn't understand what I was reading.  What
  would this be about?
 
  Thank You
 
  --
  Ian Skinner
  Web Programmer
  BloodSource
  Sacramento, CA
 
 
 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Ian Skinner
Is this a Bug in the sense that my code will not run correctly.  Or is it a
Bug in the sense that this is not a standard and/or correct behavior for an
object?

If I am understanding you correctly, using the This scope, the variables
are available inside and outside of the component, in other words they are
public properties/variables.  But a variable without a scope specification
is in this Unknown/unnamed scope and are only accessible to methods within
the component, in other words they are private.  If I code with this
understanding, does this cause a problem?

I did an experiment.  I added the following code to my CFC.

 cfset A = 5
 cfset B = 3
 
 cfset Variables.A = 7
 cfset Variables.B = 11

When I access these variables later in a method, they where set to 7 and 11.
So what is this unknown/unnamed scope?  How does it cause a problem or
affect my coding?

--
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA

-Original Message-
From: Michael Tangorre [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 10:32 AM
To: CF-Talk
Subject: Re: CFC Newbie Discussion.


Let me point out the scope bug...

using this scope exposes your data members outside of the cfc. In
addition, the variables scope is not the default for not providing a scope
within a CFC. There is something known as the unknown scope. This unknown
scope allows data members to be available to functions within the CFC... not
outside of.

this.someVar would be accessible inside and outside of the CFC
someVar would be accessible inside the CFC to the functions only. 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: CFC Newbie Discussion.

2003-06-10 Thread John Quarto-vonTivadar

 Thinking about CFCs like classes in Java or C++ is natural for me, so I
like
 to work in that mentality..

it might be more efficient to think of CFCs like CFCs, that way you can use
their features effectively, and not be disappointed or disillusioned if CFCs
do things you dont expect or dont do things you do expect

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: CFC Newbie Discussion.

2003-06-10 Thread jon hall
cfobject name=testObj component=test
cfdump var=#testObj#

cfset this.X = 12
cfset this.Y = 24

This part confuses me...this scoped variables refer to the object they
are contained within. It looks like you are setting them outside of a
cfc. All that will do is create a structure called this, which
contains x and y keys, its odd it works in the first place. I would
think this should be a reserved word in MX. Hrm.

Otherwise it's really personal preference on how to invoke your
methods. It really depends on what they return, if anything. Like
Michael I prefer createObject() for instantiating cfc though. Same
code in cfml and cfscript, plus it's just less typing.

The only big scope issue to me is the variables scope inside a cfc
being available outside of it. This could be fixed in the upcoming
release though...no way of knowing without joining the beta program
though I guess.
http://cfguru.daemon.com.au/archives/67.html

-- 
 jon
 mailto:[EMAIL PROTECTED]

Tuesday, June 10, 2003, 1:24:50 PM, you wrote:
IS I'm experimenting with my first CFC.  I've written these simple example
IS files.
snip

IS What I would like to discuss is the performance differences between the
IS various component methods I've tested here.  

IS In the CFC code, the X and Y variables are in the this scope and the A and
IS B variables are in the default variable scope.  What are the differences
IS between these practices other then the X and Y are available as properties
IS of an object (obj.X and obj.Y).

IS Then in the CFM code I accessed the component a couple different ways.  I
IS first used a cfobject tag to instantiate an instance of the component as
IS a object variable testObj.  I then accessed the methods of that instance
IS with a cfinvoke on testObj and directly [testObj.method()].  Finally I
IS just accessed the methods of the component directly with cfinvoke. 

IS I would like to discuss the pros and cons of these different practices and
IS when one might be better then another.  Also, I remember reading about some
IS kind of scope bug involving CFC's, but since I wasn't really familiar with
IS CFC's at the time, I really didn't understand what I was reading.  What
IS would this be about?

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: CFC Newbie Discussion.

2003-06-10 Thread Michael Tangorre
good point John. By the way, i got the presentation CD in the mail yesterday
from Atlanta and it was quite interersting. :-)

Anyways, I guess I tend to leverage CFCs with the object mindset, always of
the shortcomings however... and that stems from my C/C++ background.

At anyate, good point, and probably for a person new to CFCs, keeping them
focused on CFCs and not the relations to OO would be a good start.

Mike


- Original Message - 
From: John Quarto-vonTivadar [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 1:53 PM
Subject: Re: CFC Newbie Discussion.


 
  Thinking about CFCs like classes in Java or C++ is natural for me, so I
 like
  to work in that mentality..

 it might be more efficient to think of CFCs like CFCs, that way you can
use
 their features effectively, and not be disappointed or disillusioned if
CFCs
 do things you dont expect or dont do things you do expect

 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Ian Skinner
I was a bit surprised about the this scope working in the CFM file as
well.  It did just create local variables that are different then the
variables in the component object.  So they make a kind of perverted sense
if you think of the caller page as an object in it self.  I wonder if they
are different then variables scoped variables on the same page.  I'll try
that.  

Thanks for the link, I now understand what the scope bug is about.  I'll
experiment with it to get an understanding.

--
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA


-Original Message-
From: jon hall [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 11:01 AM
To: CF-Talk
Subject: Re: CFC Newbie Discussion.


cfobject name=testObj component=test
cfdump var=#testObj#

cfset this.X = 12
cfset this.Y = 24

This part confuses me...this scoped variables refer to the object they
are contained within. It looks like you are setting them outside of a
cfc. All that will do is create a structure called this, which
contains x and y keys, its odd it works in the first place. I would
think this should be a reserved word in MX. Hrm.

Otherwise it's really personal preference on how to invoke your
methods. It really depends on what they return, if anything. Like
Michael I prefer createObject() for instantiating cfc though. Same
code in cfml and cfscript, plus it's just less typing.

The only big scope issue to me is the variables scope inside a cfc
being available outside of it. This could be fixed in the upcoming
release though...no way of knowing without joining the beta program
though I guess.
http://cfguru.daemon.com.au/archives/67.html

-- 
 jon
 mailto:[EMAIL PROTECTED]

Tuesday, June 10, 2003, 1:24:50 PM, you wrote:
IS I'm experimenting with my first CFC.  I've written these simple example
IS files.
snip

IS What I would like to discuss is the performance differences between the
IS various component methods I've tested here.  

IS In the CFC code, the X and Y variables are in the this scope and the A
and
IS B variables are in the default variable scope.  What are the
differences
IS between these practices other then the X and Y are available as
properties
IS of an object (obj.X and obj.Y).

IS Then in the CFM code I accessed the component a couple different ways.
I
IS first used a cfobject tag to instantiate an instance of the
component as
IS a object variable testObj.  I then accessed the methods of that
instance
IS with a cfinvoke on testObj and directly [testObj.method()].  Finally I
IS just accessed the methods of the component directly with cfinvoke. 

IS I would like to discuss the pros and cons of these different practices
and
IS when one might be better then another.  Also, I remember reading about
some
IS kind of scope bug involving CFC's, but since I wasn't really familiar
with
IS CFC's at the time, I really didn't understand what I was reading.  What
IS would this be about?


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Raymond Camden
While I strongly urge folks to not use the This scope, I would _not_
call it a bug. The This scope works _exactly_ as advertised, it's just
not the preferred way of storing data for a CFC.

-Raymond Camen

 
 Let me point out the scope bug...
 
 using this scope exposes your data members outside of the 
 cfc. In addition, the varibales scope is not the default for 
 not providing a scope within a CFC. There is something known 
 as the unknown scope. This unknown scope allows data 
 members to be available to functions within the CFC... not outside of.
 
 this.someVar would be accessible inside and outside of the 
 CFC someVar would be accessible inside the CFC to the functions only.
 
 

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Host with the leader in ColdFusion hosting. 
Voted #1 ColdFusion host by CF Developers. 
Offering shared and dedicated hosting options. 
www.cfxhosting.com/default.cfm?redirect=10481

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Ian Skinner
So what is the Preferred way to store data for a CFC?

--
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA


-Original Message-
From: Raymond Camden [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 11:20 AM
To: CF-Talk
Subject: RE: CFC Newbie Discussion.


While I strongly urge folks to not use the This scope, I would _not_
call it a bug. The This scope works _exactly_ as advertised, it's just
not the preferred way of storing data for a CFC.

-Raymond Camen

 
 Let me point out the scope bug...
 
 using this scope exposes your data members outside of the 
 cfc. In addition, the varibales scope is not the default for 
 not providing a scope within a CFC. There is something known 
 as the unknown scope. This unknown scope allows data 
 members to be available to functions within the CFC... not outside of.
 
 this.someVar would be accessible inside and outside of the 
 CFC someVar would be accessible inside the CFC to the functions only.
 
 


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: CFC Newbie Discussion.

2003-06-10 Thread jon hall
The this scope has always worked exactly as I expected, and I do
prefer to use it to store data unless there is a specific reason not to.

-- 
 jon
 mailto:[EMAIL PROTECTED]

Tuesday, June 10, 2003, 2:20:22 PM, you wrote:
RC While I strongly urge folks to not use the This scope, I would _not_
RC call it a bug. The This scope works _exactly_ as advertised, it's just
RC not the preferred way of storing data for a CFC.

RC -Raymond Camen

 
 Let me point out the scope bug...
 
 using this scope exposes your data members outside of the 
 cfc. In addition, the varibales scope is not the default for 
 not providing a scope within a CFC. There is something known 
 as the unknown scope. This unknown scope allows data 
 members to be available to functions within the CFC... not outside of.
 
 this.someVar would be accessible inside and outside of the 
 CFC someVar would be accessible inside the CFC to the functions only.
 
 

RC 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Andy Ousterhout
Here is a summary from a few previous emails:

1.  Define properties(variables) as instance.X to prevent any outside view
or editing of them.

2.  Use getX methods to allow outside viewing, and setX methods to set
the variable.

3.  Define non-property variables used with each method through (cfset var
a=tmpVariable to prevent accidental overriding of variable used
elsewhere.

4.  Use cfproperties and Hints within cffunction and cfargument to
document your cfc.

Andy

-Original Message-
From: Ian Skinner [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 12:25 PM
To: CF-Talk
Subject: CFC Newbie Discussion.


I'm experimenting with my first CFC.  I've written these simple example
files.

*** test.cfc ***
cfcomponent displayname=My First CFC hint=A trial CFC
cfset this.X = 10
cfset this.Y = 15

cfset A = 5
cfset B = 3

cffunction name=multiplyXY access=public returntype=numeric
cfset myResult = this.X * this.Y
cfreturn myResult
/cffunction

cffunction name=multiplyAB access=public returntype=numeric
cfset myResult = A * B
cfreturn myResult
/cffunction
/cfcomponent
*** end ***

*** test.cfm ***
cfobject name=testObj component=test
cfdump var=#testObj#

cfset this.X = 12
cfset this.Y = 24

cfset A = 21
cfset B = 32

cfinvoke component=#testObj# method=multiplyXY returnvariable=joe/
cfinvoke component=#testObj# method=multiplyAB returnvariable=sam/

cfinvoke component=test method=multiplyXY returnvariable=joe2/
cfinvoke component=test method=multiplyAB returnvariable=sam2/

cfoutput
#testObj.X# * #testObj.Y# = #joe#br
#testObj.X# * #testObj.Y# = #testObj.multiplyXY()#br
#this.X# * #this.Y# = #this.X * this.Y#br
br
#sam#br
#testObj.multiplyAB()#br
#A * B#br
br
#joe2#br
#sam2#br
/cfoutput
*** end ***

What I would like to discuss is the performance differences between the
various component methods I've tested here.

In the CFC code, the X and Y variables are in the this scope and the A and
B variables are in the default variable scope.  What are the differences
between these practices other then the X and Y are available as properties
of an object (obj.X and obj.Y).

Then in the CFM code I accessed the component a couple different ways.  I
first used a cfobject tag to instantiate an instance of the component as
a object variable testObj.  I then accessed the methods of that instance
with a cfinvoke on testObj and directly [testObj.method()].  Finally I
just accessed the methods of the component directly with cfinvoke.

I would like to discuss the pros and cons of these different practices and
when one might be better then another.  Also, I remember reading about some
kind of scope bug involving CFC's, but since I wasn't really familiar with
CFC's at the time, I really didn't understand what I was reading.  What
would this be about?

Thank You

--
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: CFC Newbie Discussion.

2003-06-10 Thread Michael Tangorre
Ian,

That question is a bit vague... Remember any data in a CFC only persists for
the duration of the page request. To have it perists longer, you can load it
into the session scope for instance.



- Original Message - 
From: Ian Skinner [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 2:30 PM
Subject: RE: CFC Newbie Discussion.


 So what is the Preferred way to store data for a CFC?

 --
 Ian Skinner
 Web Programmer
 BloodSource
 Sacramento, CA


 -Original Message-
 From: Raymond Camden [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 10, 2003 11:20 AM
 To: CF-Talk
 Subject: RE: CFC Newbie Discussion.


 While I strongly urge folks to not use the This scope, I would _not_
 call it a bug. The This scope works _exactly_ as advertised, it's just
 not the preferred way of storing data for a CFC.

 -Raymond Camen

 
  Let me point out the scope bug...
 
  using this scope exposes your data members outside of the
  cfc. In addition, the varibales scope is not the default for
  not providing a scope within a CFC. There is something known
  as the unknown scope. This unknown scope allows data
  members to be available to functions within the CFC... not outside of.
 
  this.someVar would be accessible inside and outside of the
  CFC someVar would be accessible inside the CFC to the functions only.
 
 


 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: CFC Newbie Discussion.

2003-06-10 Thread Christian Cantrell
On Tuesday, June 10, 2003, at 02:20 PM, Raymond Camden wrote:

 While I strongly urge folks to not use the This scope, I would _not_
 call it a bug. The This scope works _exactly_ as advertised, it's just
 not the preferred way of storing data for a CFC.

Raymond is correct.  It is not a bug -- it's just how CFCs were 
designed to work.  If you need data publicly accessible, use of the 
this scope is fine.  If you need your data to be private, either use 
the unnamed scope, or create your own private struct.  I would 
recommend keeping data as private as possible, however if you don't 
feel you need to, or it doesn't fit with your architecture, then do 
what is best for you.

Christian

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Raymond Camden
One good reason to keep data private, even if it doesn't seem important:
If you keep it private from the get go, and build get/set functions, and
then later on realize it really does need to be private, you don't have
to update any of your caller code.


===
Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
(www.mindseye.com)
Member of Team Macromedia (http://www.macromedia.com/go/teammacromedia)

Email: [EMAIL PROTECTED]
Blog : www.camdenfamily.com/morpheus/blog
Yahoo IM : morpheus

My ally is the Force, and a powerful ally it is. - Yoda 

 -Original Message-
 From: Christian Cantrell [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, June 10, 2003 12:40 PM
 To: CF-Talk
 Subject: Re: CFC Newbie Discussion.
 
 
 On Tuesday, June 10, 2003, at 02:20 PM, Raymond Camden wrote:
 
  While I strongly urge folks to not use the This scope, I 
 would _not_ 
  call it a bug. The This scope works _exactly_ as 
 advertised, it's just 
  not the preferred way of storing data for a CFC.
 
 Raymond is correct.  It is not a bug -- it's just how CFCs were 
 designed to work.  If you need data publicly accessible, use of the 
 this scope is fine.  If you need your data to be private, 
 either use 
 the unnamed scope, or create your own private struct.  I would 
 recommend keeping data as private as possible, however if you don't 
 feel you need to, or it doesn't fit with your architecture, then do 
 what is best for you.
 

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Host with the leader in ColdFusion hosting. 
Voted #1 ColdFusion host by CF Developers. 
Offering shared and dedicated hosting options. 
www.cfxhosting.com/default.cfm?redirect=10481

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Ian Skinner
Ahh, I understand now, the best practice we are talking about is protecting
the state/variables of ones objects, but using private variables and
functions to manipulate them.  I would generally agree with that as well,
for a little as I've used objects in programming to date.  I'm just trying
to get as complete a picture of how each scope and access behaves so I can
better know how to write code that will do what I want it and how to debug
it when it doesn't.


A question on the variables scope bug in a CFC.  The link provided earlier
stated that a variable defined in a CFC using the variables scope would be
accessible to the methods of the component (proper) as well as the calling
template (improper/bug).  But in my experiments I found the variables I
scoped with variables where ONLY accessible to the calling template and
not any of the methods in the CFC.  Is this bug bigger then I understand, or
is something else going on here?

Example
cfcomponent
cfset Variables.A = 7
cfset Variables.B = 11

cffunction name=multiplyAB1 access=public returntype=numeric
cfset myResult = A * B
cfreturn myResult
/cffunction
/cfcomponent

In this example, I get an error stating that the variable A is not defined?

--
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA


-Original Message-
From: Christian Cantrell [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 11:40 AM
To: CF-Talk
Subject: Re: CFC Newbie Discussion.


On Tuesday, June 10, 2003, at 02:20 PM, Raymond Camden wrote:

 While I strongly urge folks to not use the This scope, I would _not_
 call it a bug. The This scope works _exactly_ as advertised, it's just
 not the preferred way of storing data for a CFC.

Raymond is correct.  It is not a bug -- it's just how CFCs were 
designed to work.  If you need data publicly accessible, use of the 
this scope is fine.  If you need your data to be private, either use 
the unnamed scope, or create your own private struct.  I would 
recommend keeping data as private as possible, however if you don't 
feel you need to, or it doesn't fit with your architecture, then do 
what is best for you.

Christian


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Raymond Camden
This is due to a known bug. In general, just leave off Variables, or,
use your own struct:

cfset local = structNew()
cfset local.a = jedi

By the way, there is one more scope you should be convered with - and
that is 'var' scoped method variables. Whenever you use a value in a
method, a value that is NOT meant to exist in the CFC whole, you should
use the var scope. Here is an example:

cffunction name=getCrap .
cfargument name=id 
cfset var myQuery = 

cfquery name=myQuery ...
...
/cfqyery

cfreturn myQuery

/cffunction

ANY variable created inside a method should be var scoped (unless you
want it to exists outside the method). Don't forget things like
cfquery create values, ditto for cfdirectory, etc.



===
Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
(www.mindseye.com)
Member of Team Macromedia (http://www.macromedia.com/go/teammacromedia)

Email: [EMAIL PROTECTED]
Blog : www.camdenfamily.com/morpheus/blog
Yahoo IM : morpheus

My ally is the Force, and a powerful ally it is. - Yoda 

 -Original Message-
 From: Ian Skinner [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, June 10, 2003 12:49 PM
 To: CF-Talk
 Subject: RE: CFC Newbie Discussion.
 
 
 Ahh, I understand now, the best practice we are talking about 
 is protecting the state/variables of ones objects, but using 
 private variables and functions to manipulate them.  I would 
 generally agree with that as well, for a little as I've used 
 objects in programming to date.  I'm just trying to get as 
 complete a picture of how each scope and access behaves so I 
 can better know how to write code that will do what I want it 
 and how to debug it when it doesn't.
 
 
 A question on the variables scope bug in a CFC.  The link 
 provided earlier stated that a variable defined in a CFC 
 using the variables scope would be accessible to the methods 
 of the component (proper) as well as the calling template 
 (improper/bug).  But in my experiments I found the variables 
 I scoped with variables where ONLY accessible to the 
 calling template and not any of the methods in the CFC.  Is 
 this bug bigger then I understand, or is something else going on here?
 
 Example
 cfcomponent
   cfset Variables.A = 7
   cfset Variables.B = 11
 
   cffunction name=multiplyAB1 access=public 
 returntype=numeric
   cfset myResult = A * B
   cfreturn myResult
   /cffunction
 /cfcomponent
 
 In this example, I get an error stating that the variable A 
 is not defined?
 
 --
 Ian Skinner
 Web Programmer
 BloodSource
 Sacramento, CA
 
 
 -Original Message-
 From: Christian Cantrell [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 10, 2003 11:40 AM
 To: CF-Talk
 Subject: Re: CFC Newbie Discussion.
 
 
 On Tuesday, June 10, 2003, at 02:20 PM, Raymond Camden wrote:
 
  While I strongly urge folks to not use the This scope, I 
 would _not_ 
  call it a bug. The This scope works _exactly_ as 
 advertised, it's just 
  not the preferred way of storing data for a CFC.
 
 Raymond is correct.  It is not a bug -- it's just how CFCs were 
 designed to work.  If you need data publicly accessible, use of the 
 this scope is fine.  If you need your data to be private, 
 either use 
 the unnamed scope, or create your own private struct.  I would 
 recommend keeping data as private as possible, however if you don't 
 feel you need to, or it doesn't fit with your architecture, then do 
 what is best for you.
 
 Christian
 
 
 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: CFC Newbie Discussion.

2003-06-10 Thread Michael Tangorre
You are asking all the right quesitons to learn... keep asking.  :-)

to keep variables protected within functions, use:
cfset var myvariable = something

to keep variables protected to the cfc and functions within the cfc, use:
your own structure or use no scope.
cfset myvariable = something

to allow variables to be exposed to the cfc (including the functions) as
well as the calling templates, use:
cfset this.myvariable = something

In terms of the variables scope you get an error on, to be honost, I do not
know. I do not use the variables scope within CFCs. Id be interested to know
though.

Hope this helps you.

Mike



- Original Message - 
From: Ian Skinner [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 2:49 PM
Subject: RE: CFC Newbie Discussion.


 Ahh, I understand now, the best practice we are talking about is
protecting
 the state/variables of ones objects, but using private variables and
 functions to manipulate them.  I would generally agree with that as well,
 for a little as I've used objects in programming to date.  I'm just trying
 to get as complete a picture of how each scope and access behaves so I can
 better know how to write code that will do what I want it and how to debug
 it when it doesn't.


 A question on the variables scope bug in a CFC.  The link provided
earlier
 stated that a variable defined in a CFC using the variables scope would be
 accessible to the methods of the component (proper) as well as the calling
 template (improper/bug).  But in my experiments I found the variables I
 scoped with variables where ONLY accessible to the calling template and
 not any of the methods in the CFC.  Is this bug bigger then I understand,
or
 is something else going on here?

 Example
 cfcomponent
 cfset Variables.A = 7
 cfset Variables.B = 11

 cffunction name=multiplyAB1 access=public returntype=numeric
 cfset myResult = A * B
 cfreturn myResult
 /cffunction
 /cfcomponent

 In this example, I get an error stating that the variable A is not
defined?

 --
 Ian Skinner
 Web Programmer
 BloodSource
 Sacramento, CA


 -Original Message-
 From: Christian Cantrell [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 10, 2003 11:40 AM
 To: CF-Talk
 Subject: Re: CFC Newbie Discussion.


 On Tuesday, June 10, 2003, at 02:20 PM, Raymond Camden wrote:

  While I strongly urge folks to not use the This scope, I would _not_
  call it a bug. The This scope works _exactly_ as advertised, it's just
  not the preferred way of storing data for a CFC.

 Raymond is correct.  It is not a bug -- it's just how CFCs were
 designed to work.  If you need data publicly accessible, use of the
 this scope is fine.  If you need your data to be private, either use
 the unnamed scope, or create your own private struct.  I would
 recommend keeping data as private as possible, however if you don't
 feel you need to, or it doesn't fit with your architecture, then do
 what is best for you.

 Christian


 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Host with the leader in ColdFusion hosting. 
Voted #1 ColdFusion host by CF Developers. 
Offering shared and dedicated hosting options. 
www.cfxhosting.com/default.cfm?redirect=10481

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Ian Skinner
Thanks, this is actually beginning to make some sense.  As to the
variables.A throwing an error, I figured out that I wasn't being consistent
in my naming.  I set it as variables.A, but then I called it in the
calculation as just A.  When I changed that call to variables.A everything
worked/didn't work just as described.  Reinforcing that the variables scope
and the un-named scope are completely different and don't share information.

--
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA


-Original Message-
From: Michael Tangorre [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 11:57 AM
To: CF-Talk
Subject: Re: CFC Newbie Discussion.


You are asking all the right quesitons to learn... keep asking.  :-)

to keep variables protected within functions, use:
cfset var myvariable = something

to keep variables protected to the cfc and functions within the cfc, use:
your own structure or use no scope.
cfset myvariable = something

to allow variables to be exposed to the cfc (including the functions) as
well as the calling templates, use:
cfset this.myvariable = something

In terms of the variables scope you get an error on, to be honost, I do not
know. I do not use the variables scope within CFCs. Id be interested to know
though.

Hope this helps you.

Mike



- Original Message - 
From: Ian Skinner [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 2:49 PM
Subject: RE: CFC Newbie Discussion.


 Ahh, I understand now, the best practice we are talking about is
protecting
 the state/variables of ones objects, but using private variables and
 functions to manipulate them.  I would generally agree with that as well,
 for a little as I've used objects in programming to date.  I'm just trying
 to get as complete a picture of how each scope and access behaves so I can
 better know how to write code that will do what I want it and how to debug
 it when it doesn't.


 A question on the variables scope bug in a CFC.  The link provided
earlier
 stated that a variable defined in a CFC using the variables scope would be
 accessible to the methods of the component (proper) as well as the calling
 template (improper/bug).  But in my experiments I found the variables I
 scoped with variables where ONLY accessible to the calling template and
 not any of the methods in the CFC.  Is this bug bigger then I understand,
or
 is something else going on here?

 Example
 cfcomponent
 cfset Variables.A = 7
 cfset Variables.B = 11

 cffunction name=multiplyAB1 access=public returntype=numeric
 cfset myResult = A * B
 cfreturn myResult
 /cffunction
 /cfcomponent

 In this example, I get an error stating that the variable A is not
defined?

 --
 Ian Skinner
 Web Programmer
 BloodSource
 Sacramento, CA


 -Original Message-
 From: Christian Cantrell [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 10, 2003 11:40 AM
 To: CF-Talk
 Subject: Re: CFC Newbie Discussion.


 On Tuesday, June 10, 2003, at 02:20 PM, Raymond Camden wrote:

  While I strongly urge folks to not use the This scope, I would _not_
  call it a bug. The This scope works _exactly_ as advertised, it's just
  not the preferred way of storing data for a CFC.

 Raymond is correct.  It is not a bug -- it's just how CFCs were
 designed to work.  If you need data publicly accessible, use of the
 this scope is fine.  If you need your data to be private, either use
 the unnamed scope, or create your own private struct.  I would
 recommend keeping data as private as possible, however if you don't
 feel you need to, or it doesn't fit with your architecture, then do
 what is best for you.

 Christian


 

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: CFC Newbie Discussion.

2003-06-10 Thread Jeff
on 6/10/03 2:55 PM, Raymond Camden at [EMAIL PROTECTED] wrote:

 By the way, there is one more scope you should be convered with - and
 that is 'var' scoped method variables. Whenever you use a value in a
 method, a value that is NOT meant to exist in the CFC whole, you should
 use the var scope. Here is an example:
 
 cffunction name=getCrap .
 cfargument name=id 
 cfset var myQuery = 
 
 cfquery name=myQuery ...
 ...
 /cfqyery
 
 cfreturn myQuery
 
 /cffunction

So this example was meant to show how to protect variables inside the
method? If I follow correctly, you created a variable scoped to the 'var'
scope (named myQuery), then set the variable equal to the value of the
Query? Does this mean that, if I follow what you say below...
 
 ANY variable created inside a method should be var scoped (unless you
 want it to exists outside the method). Don't forget things like
 cfquery create values, ditto for cfdirectory, etc.

...that normally, a query object that would be created, as a result of
performing a query, are now only available to that method (since you scoped
it 'var') and as soon as the object is no longer being used, the variable
'disappears' as part of the whole CFC garbage collection?

Is it garbage collection?

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Raymond Camden
 
 So this example was meant to show how to protect variables 
 inside the method? If I follow correctly, you created a 
 variable scoped to the 'var' scope (named myQuery), then 
 set the variable equal to the value of the Query? Does this 
 mean that, if I follow what you say below...


Correct. Because you have to set a value IMMIDIATELY when you var
scoped, I just use the empty string.

  ANY variable created inside a method should be var scoped 
 (unless you 
  want it to exists outside the method). Don't forget things like 
  cfquery create values, ditto for cfdirectory, etc.
 
 ...that normally, a query object that would be created, as a 
 result of performing a query, are now only available to that 
 method (since you scoped it 'var') and as soon as the object 
 is no longer being used, the variable 'disappears' as part of 
 the whole CFC garbage collection?

Yes.

 Is it garbage collection?

I've been reamed before for daring to not use the _exact_ precise word,
so, I'll say, maybe, yea, probably so. ;)

ducks the language police

-rc

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Host with the leader in ColdFusion hosting. 
Voted #1 ColdFusion host by CF Developers. 
Offering shared and dedicated hosting options. 
www.cfxhosting.com/default.cfm?redirect=10481

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Ian Skinner
Two follow up questions.  You can't directly use the var key word in the
cfquery tag; cfquery name=var joe  Also, when exactly does this
data get garbage collected?  Since it is in a method, does a query get
created and destroyed every time that method is used?  I does it persist for
the life of the entire component?

--
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA


-Original Message-
From: Raymond Camden [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 12:38 PM
To: CF-Talk
Subject: RE: CFC Newbie Discussion.


 
 So this example was meant to show how to protect variables 
 inside the method? If I follow correctly, you created a 
 variable scoped to the 'var' scope (named myQuery), then 
 set the variable equal to the value of the Query? Does this 
 mean that, if I follow what you say below...


Correct. Because you have to set a value IMMIDIATELY when you var
scoped, I just use the empty string.

  ANY variable created inside a method should be var scoped 
 (unless you 
  want it to exists outside the method). Don't forget things like 
  cfquery create values, ditto for cfdirectory, etc.
 
 ...that normally, a query object that would be created, as a 
 result of performing a query, are now only available to that 
 method (since you scoped it 'var') and as soon as the object 
 is no longer being used, the variable 'disappears' as part of 
 the whole CFC garbage collection?

Yes.

 Is it garbage collection?

I've been reamed before for daring to not use the _exact_ precise word,
so, I'll say, maybe, yea, probably so. ;)

ducks the language police

-rc


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Host with the leader in ColdFusion hosting. 
Voted #1 ColdFusion host by CF Developers. 
Offering shared and dedicated hosting options. 
www.cfxhosting.com/default.cfm?redirect=10481

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC Newbie Discussion.

2003-06-10 Thread Raymond Camden
 
 Two follow up questions.  You can't directly use the var key 
 word in the cfquery tag; cfquery name=var joe  

Correct. You also can't do cfset var ... after any line of real code.
So, your first N lines of a method will be cfargument tags, then cfset
var tags, then 'real' code. 

So, that's why you saw me do:

cfset var q = 

cfquery name=q .


 Also, when exactly does this data get garbage collected?  

Um, I'm assuming when the method is done.

 Since it is in a method, does a query get created and 
 destroyed every time that method is used?  I does it persist 
 for the life of the entire component?
 

The query does NOT persist because I used the var scope. However,
imagine a case where you query to get the states in the US. This will
not change anytime soon. Your code could look like so (pseudo-code):

(above, in the constructor area)
cfset local = structNew()

cffunction name=getStates 

cfset var q = 

cfif not structKeyExists(local,states)
run a query and get the states in query named q
cfset local.q = duplicate(q)
/cfif

cfreturn local.q

/cffunction

In this example, the query persists as long as the CFC persists.


===
Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
(www.mindseye.com)
Member of Team Macromedia (http://www.macromedia.com/go/teammacromedia)

Email: [EMAIL PROTECTED]
Blog : www.camdenfamily.com/morpheus/blog
Yahoo IM : morpheus

My ally is the Force, and a powerful ally it is. - Yoda 

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: CFC newbie

2002-10-18 Thread Thomas Chiverton
 cfinvoke component=com.locavista.gui method=header
That should read com.local.gui sorry, mis-typed into Outlook, so still
broken...


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm



RE: CFC newbie

2002-10-18 Thread Michael Corbridge
create a CF mapping for 'com' 

-Original Message-
From: Thomas Chiverton [mailto:thomas.chiverton;locavista.com]
Sent: Friday, October 18, 2002 11:05 AM
To: CF-Talk
Subject: RE: CFC newbie


 cfinvoke component=com.locavista.gui method=header
That should read com.local.gui sorry, mis-typed into Outlook, so still
broken...



~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.



RE: CFC newbie

2002-10-18 Thread Mark A. Kruger - CFG
Actually, the last object label in the dotted notation should be the name of
the file:

cfinvoke component=com.locavista.gui.header method=someMethod

-Original Message-
From: Michael Corbridge [mailto:mcorbridge;macromedia.com]
Sent: Friday, October 18, 2002 10:21 AM
To: CF-Talk
Subject: RE: CFC newbie


create a CF mapping for 'com'

-Original Message-
From: Thomas Chiverton [mailto:thomas.chiverton;locavista.com]
Sent: Friday, October 18, 2002 11:05 AM
To: CF-Talk
Subject: RE: CFC newbie


 cfinvoke component=com.locavista.gui method=header
That should read com.local.gui sorry, mis-typed into Outlook, so still
broken...




~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com



RE: CFC newbie

2002-10-18 Thread Thomas Chiverton
 create a CF mapping for 'com'

Ahh, great ! That was it.

Friday brain fade - the sub dir I was in was mapped, so the 'com' directory
I created was in the wrong place. Moving it to the actual wwwroot worked a
treat.

Tom Chiverton
You don't have to be a mad scientist to believe in ColdFusion




~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.



RE: CFC newbie

2002-10-18 Thread S . Isaac Dealey
I have some recollection of someone on this list mentioning that com might
cause problems in paths ( I think it was with relation to CFC's ) as a
result of it having a significant meaning to the operating system -- though
that's just random recollected heresay. I've also heard that having com in a
url can cause problems as a result of it's significant meaning to dns and
how some browsers handle domain names... though that in particular shouldn't
matter in a cfc.

 Actually, the last object label in the dotted notation should be the name
 of
 the file:

 cfinvoke component=com.locavista.gui.header method=someMethod

 -Original Message-
 From: Michael Corbridge [mailto:mcorbridge;macromedia.com]
 Sent: Friday, October 18, 2002 10:21 AM
 To: CF-Talk
 Subject: RE: CFC newbie


 create a CF mapping for 'com'

 -Original Message-
 From: Thomas Chiverton [mailto:thomas.chiverton;locavista.com]
 Sent: Friday, October 18, 2002 11:05 AM
 To: CF-Talk
 Subject: RE: CFC newbie


 cfinvoke component=com.locavista.gui method=header
 That should read com.local.gui sorry, mis-typed into Outlook, so still
 broken...




 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm



RE: CFC newbie question

2002-09-05 Thread Michael Corbridge

Ali,

Here is a stripped down version of your cfc that works with the native 'exampleapps' 
datasource that is shipped with  CFMX.

Notes:

You have set the method access='private' which means that method can only be called 
from another method in the component.  When starting out with cfc's, I would ignore 
the access attrib. until you get comfortable with the basic architecture.


I also note that in your cfc, the return var is 'binary', however you are returning a 
'boolean'


__
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: CFC newbie question

2002-09-05 Thread Michael Corbridge

h...

all the example code was removed from my previous email.
I'll try again.


cftalk1.cfm
---
cfinvoke component=cftalk1 method=sendMail emailid=Raymond 
returnVariable=r_return
cfdump var=#r_return#

cftalk1.cfc

CFCOMPONENT hint=Database Driven Email Processing
 CFFUNCTION name=sendMail access=private returntype=boolean hint=Process 
Emails
  
CFARGUMENT name=emailID type=string required=true hint=ID of Email to send   


CFQUERY NAME=queryemail DATASOURCE=exampleapps
SELECT
*
FROM
tblEmployees
WHERE
FirstName = '#emailID#'
/CFQUERY

cfmail to = [EMAIL PROTECTED]
  from = [EMAIL PROTECTED]
  subject = test 

test from cfc
#queryemail.LastName#

/cfmail


  cfset success = True
  CFRETURN success
 /CFFUNCTION
/CFCOMPONENT


__
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: CFC newbie question

2002-09-05 Thread Raymond Camden

Please remember to use the var scope. In the method below, both
queryemail and success need to be var-ed. (I'd also add output=false.)

===
Raymond Camden, ColdFusion Jedi Master for Hire

Email: [EMAIL PROTECTED]
Yahoo IM : cfjedimaster

My ally is the Force, and a powerful ally it is. - Yoda 

 -Original Message-
 From: Michael Corbridge [mailto:[EMAIL PROTECTED]] 
 Sent: Thursday, September 05, 2002 8:18 AM
 To: CF-Talk
 Subject: RE: CFC newbie question
 
 
 h...
 
 all the example code was removed from my previous email.
 I'll try again.
 
 
 cftalk1.cfm
 ---
 cfinvoke component=cftalk1 method=sendMail 
 emailid=Raymond returnVariable=r_return
 cfdump var=#r_return#
 
 cftalk1.cfc
 
 CFCOMPONENT hint=Database Driven Email Processing
  CFFUNCTION name=sendMail access=private 
 returntype=boolean hint=Process Emails
   
 CFARGUMENT name=emailID type=string required=true 
 hint=ID of Email to send   
 
 
 CFQUERY NAME=queryemail DATASOURCE=exampleapps
   SELECT
   *
   FROM
   tblEmployees
   WHERE
   FirstName = '#emailID#'
 /CFQUERY
 
 cfmail to = [EMAIL PROTECTED]
   from = [EMAIL PROTECTED]
   subject = test 
 
   test from cfc
   #queryemail.LastName#
 
 /cfmail
 
 
   cfset success = True
   CFRETURN success
  /CFFUNCTION
 /CFCOMPONENT
 

 


__
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: CFC newbie question

2002-09-04 Thread Raymond Camden

You forgot you # signs...

 cfmail subject=queryemail.tblemails_subject
   to=queryemail.tblemails_to 
   from=queryemail.tblemails_from 

should be

 cfmail subject=#queryemail.tblemails_subject#
   to=#queryemail.tblemails_to# 
   from=#queryemail.tblemails_from# 

Not a CFC issue - just a syntax issue.

===
Raymond Camden, ColdFusion Jedi Master for Hire

Email: [EMAIL PROTECTED]
Yahoo IM : cfjedimaster

My ally is the Force, and a powerful ally it is. - Yoda 

 -Original Message-
 From: Ali Daniali [mailto:[EMAIL PROTECTED]] 
 Sent: Wednesday, September 04, 2002 8:52 PM
 To: CF-Talk
 Subject: CFC newbie question
 
 
 After hearing about CFCs and reading about CFCs I have finally decided
 to write my first CFC. But I'm not sure if I have this whole 
 CFC concept
 figured out. Below is my first CFC. I have not been able to get it to
 work and was wondering if someone might be able to give me some help.
  
 Basically I have a database table with a whole bunch of 
 emails that can
 be sent during a particular online application. Instead of embedding
 CFMAIL one after another in my code I wanted to separate it 
 all...enter
 CFCs...right?
  
 So I evoke this CFC passing an email ID argument to the the
 component...it looks it up the email ID in the database and zap...its
 supposed to send the right emailso here it iswhat am I doing
 wrong?
  
 Thank you in advance
  
 CFCOMPONENT hint=Database Driven Email Processing
  CFFUNCTION name=sendMail access=private returntype=binary
 hint=Process Emails
   CFARGUMENT name=emailID type=numeric required=true 
 hint=ID of
 Email to send   
 cftry
   CFQUERY name=queryemail datasource=dbEP3
    SELECT *
    FROM tblemails
    WHERE tblemails_ID = ARGUMENTS.emailID
   /CFQUERY
 cfmail subject=queryemail.tblemails_subject
   to=queryemail.tblemails_to 
   from=queryemail.tblemails_from 
   cc=queryemail.tblemails_cc 
   bcc=queryemail.tblemails_bcc 
   query=queryemail.tblemails_query1 
   server=queryemail.tblemails_server 
   type=queryemail.tblemails_type
 #queryemail.tblemails_message1##queryemail.tblemails_message2#
 /cfmail
 CFCATCH type=databasecfset success = FalseCFRETURN
 success/CFCATCH
 CFCATCh type=anycfset success = FalseCFRETURN 
 success/CFCATCh
 /cftry
   cfset success = True
   CFRETURN success
  /CFFUNCTION
 /CFCOMPONENT
  
 Best Regards,
 Ali Daniali
  
 
 Ali Daniali
 Director, Development and Programming
 TransACT Communications, Inc.
 8423 Mukilteo Speedway, Suite 100
 Mukilteo, WA 98275
 Tel: 425.977.2117
 FAX: 425.977.2080
 Email: [EMAIL PROTECTED]
 
 


__
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists