Learning CF9: Why Don't My Comment-Based Attributes Work?

Posted on October 22, 2009 at 6:08 PM in ColdFusion

If you're like me, you absolutely love CF9's new script-based CFCs. I recently re-worked a very simple class and went from 111 lines of code in my old tag-based version down to 66 lines of code in the new all-script version. Nice! But I was having trouble getting comment-based attributes for the component, properties, and functions to actually work.

According to the CF9 docs, you can use comments to create the various bits of metadata for your CFC. For example:

  1. /**
  2. * I am the hint for a simple component
  3. */
  4. component {
  5. }

In the above example, the plain text in the comment is the equivalent of using the hint="" attribute on the <cfcomponent> tag. What the docs do not tell you is that you *must* use that exact opening syntax. That is, an opening slash followed by two (or more) asterisks (*).

I have always used a similar syntax, but with just a single asterisk, like so:

  1. /*
  2. * I am the hint for a simple component
  3. */
  4. component {
  5. }

It took me forever to figure out why my comment-based metadata was not working properly. Hopefully by writing this post I not only remember it myself, but also help someone else out in the process. :-)

Comments
(Comment Moderation is enabled. Your comment will not appear until approved.)

On 10/22/09 at 6:34 PM, andy matthews said:

The difference comes from JavaDoc style notations newly created in CF9. There's apparently a hullabaloo over them:

http://www.danvega.org/blog/index.cfm/2009/8/24/Co...

On 10/22/09 at 7:30 PM, Matt Quackenbush said:

@ Andy - Thanks for the link. I am not sure how I feel about using this style for attribute/metadata settings. On the one hand, it is technically not actually a comment, but rather a very specific form of notation. On the other hand, an IDE (correctly) styles it as a comment. The one thing I do know is that I loathe the idea of mixing script syntax with foo="bar" syntax (although I may end up using it anyways). Like everything else, I suppose my likes/dislikes and coding habits will evolve over time.
CodeBassRadio

Latest Articles

Eventually something really brilliant and witty will appear right here.

Calendar

March 2026
S M T W T F S
« Feb  
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

Subscribe

Enter a valid email address.

The Obligatory Wish List