Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Using 'variables.instance' structure and implicit getters/setters

Enthusiast ,
Dec 13, 2013 Dec 13, 2013

I am adopting the use of creating a variables.instance (I use 'variables.my') structure to separate instance data from the object, however I have a question when it comes to ColdFusion creating implicit getters and setters based on that object's defined properties.

BEFORE, if I had a Name property, CF would create getName() and setName() for me, and it would update the variables.Name private variable accordingly in each.  But now that my variables are being stored in 'variables.my.Name', does this mean I can no longer use ColdFusion's implicit getters and setters? (because it would improperly be attempting to execute getName and be looking for variables.Name, when that data now exists in variables.my.Name?

Are there any methodologies around that allow me to utilize CF's implicit getters/setters while using this 'my' instance variable and have them work with one another?

724
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 13, 2013 Dec 13, 2013

Yes, nesting the component's variables into a custom structure (like variables.instance or variables.my) will break the implicit getter/setter functionality.  You'll have to explicitly create getter and setter methods.

-Carl V.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2013 Dec 13, 2013

Thanks for the confirmation Carl.

How cool, then, would it be if ColdFusion 11 supported something like:

<cfcomponent

     accessors="true"

     implicitpropertyprefix="my."

     ...

That way I could specify "my." as the property prefix and when it goes to create those implicit getters and settings, it will concatenate that into 'variables.my.' as the prefix when it alters property values or returns them.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 13, 2013 Dec 13, 2013

Sounds like a great Enhancement Request to put in the bug tracker.

-Carl V.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2013 Dec 13, 2013
LATEST

To the bug tracker!  *rushes off*

** UPDATE ** Hmm, seems cfbugs.adobe.com is resetting the connection repeatedly.  <philosophical>Can one submit a bug into a bug reporting system that is experiencing a bug?</philosophical>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources