I have a Newsletter object based on a db table with the following fields: newsletterId (int) broadcastDateTime (dateTime) templateId (int) templateData (text)
I have a templateData object, which is basically just a wrapper for a struct that contains key/value pairs, which VARY based on which template is chosen for the newsletter. When I "load up" a newsletter, I create the Newsletter object first, in session scope. Then I dynamically load a TemplateData object, again based on the user's chosen template. The TemplateData object loads some default values, and is stored, as an object, in the Newsletter object. The templateData object has a function, getTemplateDataAsWddx(), which converts the instance variables into a WDDX-encoded struct. When I call newsletter.save(), of course it is trying to save the templateData object into the database directly, which is not allowed because it's an object, not a text string. So, I need to override the newsletter.save() function, so that before the save goes to the database, the object that is in newsletter.getTemplateData() is "converted" to wddx, hopefully by calling the getTemplateDataAsWddx(). So, in the database the newsletter's "templateData" field is a wddx-encoded string, but when pulled out, that string is used to populate an actual TemplateData object. Right now I'm working on the "get it into the database" part. :) A little convoluted, I know, but I need the template data to be flexible - it's the "data that changes" in the concept of "encapsulate what changes". The system can support adding more templates simply by creating additional template-specific TemplateData cfc's, which extend a BaseTemplateData cfc, and creating the associated html template. So... how can I modify newsletter.save() such that it knows to take the object that's in newsletter.getTemplateData() and "serialize" it before trying to store it? If you choose to dig into this, thank you in advance! Marc -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Reactor for ColdFusion Mailing List [email protected] Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
