ColdFusion 9 Property Annotations
I actually came across this feature while listening to the cfhour podcast. A lot of this came from the basis of the new quicksilver framework . I knew that you could use annotations in comments for properties and components. This is an example of component written in script that describes attributes of the component and properties using annotations. These are all attributes that are all documented and can be used in tag versions.
This is great but its really just another way to describe the component or property using another method. What if you wanted to provide your own custom attributes to the property or component? You can do so by simply adding them to the comments right above your property or component. It's important to note that /** is different than /*. With this in mind I thought this would be a great place to be able to sprinkle validation in to my Entities. In this example I have a user entity that I have defined some custom attributes.
That is great but as it is right now it really is not much help to us because we have no way to get that data. Well thanks to ColdFusion 9 we actually do. The getMetaData will actually give us back the annotations.
If you look at the dump of the meta data you will notice that we have an array of properties with a key/pair value for each annotation we defined. This gives the ability to add some really cool functionality to our applications.
This to me is just awesome because it allows us to sprinkle some extra functionality into our components very easily. With this new found knowledge we could also create some handy methods in our Abstract Entity.
I had no idea any of this was possible until I really started looking the new QuickSilver framework and listening to some podcasts. If you want to learn more about the framework I would listen to the 1st episode This Week In ColdFusion.
*** UPDATE ***
It is important to note that this can be done using tags as well.
*** UPDATE ***
Apparently this can be done in older version of CF, that is news to me. You could not do this in script in older version so to me its a new feature!
