Thanks for that. As this piece unfolds, I see that there might be a wrinkle in setting the default in the TO.
Consider this: The domain objects in question are AddressRecord and CountryRecord. The property is question is AddressRecord.countryID, and the default value would be "1". I have a function, CountryRecord.getUSID(), which returns "1" (The ID of the US, in my Country table). This is so I don't have the mysterious "1" value in many different places. For instance, I've got business logic that depends on CountryRecord.getUSID(), such as the function AddressRecord.isInUS(). Ideally, I'd want to default the Address.countryId property to CountryRecord.getUSID(), instead of the mysterious "1" value, but I don't think I can call such a function in the TO. Am I overthinking this, or is the desire to factor the "1" value a valid concern? Thanks, Jamie Side note: Now that I think about it, getUSID() probably doesn't belong in CountryRecord, because why would a Country object know what the country ID of the US is. I guess this intelligence probably belongs in a manager or service, or something, but in any case, it seems it belongs in the model somewhere. Therefore, I think all of the above information applies, except probably the placement of getUSID(). On 6/18/08, Chris Blackwell <[EMAIL PROTECTED]> wrote: > The place to do this is in the TO's, for example.. > > <cfcomponent hint="I am the database agnostic custom TO object for the Order > object. I am generated, but not overwritten if I exist. You are safe to > edit me." > extends="reactor.project.foo.To.OrderTo"> > <!--- Place custom code here, it will not be overwritten ---> > > <cfset this.DateCreated = now() /> > > </cfcomponent> > > Chris > > 2008/6/18 Jamie Jackson <[EMAIL PROTECTED]>: > > > Where's the most appropriate place to put a default value for a Record > property? > > > > There are several places I can think of to do it: The view (not > > reusable; view needs to be smart), the TO, and the Record. > > > > Say I want an Address's stateId to default to "1" (US), where's the > > best place (in the model) for this? If it "depends," please help me > > understand what those dependencies might be? > > > > Thanks, > > Jamie > > > > > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > -- -- > > Reactor for ColdFusion Mailing List > > [EMAIL PROTECTED] > > Archives at: > http://www.mail-archive.com/reactor%40doughughes.net/ > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > -- -- > > > > > > > > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > -- -- > Reactor for ColdFusion Mailing List > [EMAIL PROTECTED] > Archives at: > http://www.mail-archive.com/reactor%40doughughes.net/ > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Reactor for ColdFusion Mailing List [EMAIL PROTECTED] Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
