Using a Decorator with Transfer

Transfer was built to allow you to extend its capabilities. Using the Decorator Pattern you can overlay/overwrite methods of a TransferObject and add methods of your own. Remember its a Decorator to the Transfer Object(the Bean). So the methods you add should be relative to the Bean. To add DB or other external functions, there are other ways.

Here’s how you setup the Decorator.

1. Add the decorator attribute to the object element in your Transfer Config XML file.

2. Create your Decorator CFC and extend the Transfer Decorator Object.

You also have access to getTransfer() when you extend the Transfer Decorator Object.

That’s it. Re-init Transfer and your Decorator methods will now be available from your Transfer Objects.

To take it a step further, I have created a Base Decorator to share methods accross Decorators. But that’s another Blog.

Leave a Reply

Your email address will not be published. Required fields are marked *