0 Replies Latest reply: Sep 28, 2013 9:07 AM by Aegis Kleais RSS

    THIS scope and VARIABLES scope and ACCESSORS, oh snap.

    Aegis Kleais Community Member

      In my continued attempts at learning ColdFusion, I've stumbled upon an area of components which has me asking more questions than the book is answering, so I am looking for clarification if possible. (Please correct me if I'm wrong)

       

      A component has a VARIABLES scope.  This scope is private to the component and its methods.  It also has a THIS scope, which contains variables which can be accessed by other components.  Each method within the component has a LOCAL scope, which are variables that are seen by that method only.  Hopefully I'm on the right track.

       

      I just got into a lesson on Accessors.  So, these are get___() and set___() methods which are created once we put the accessors="true" attribute on our component.  And they look at properties that are defined to determine which accessors to create.  So, I've tested and I can call a component from another location, like: REQUEST.coms.response.getPropertyName() and sure enough, it returns the value.  I can also do the set() equivalent and all is good there as well.

       

      So what I've yet to figure out, is how do these properties differ from public THIS-scoped variables which can be both accessed and modified by other locations?  What are your deciding factors as to why you'd have a value be stored as a property of a component vs a variable?