Hey Matt, there are a couple of good threads that might help you. One titled
"[CFCDEV] Service Layer X OO Architecture" discusses the problem of passing
back both messages and an object. Another thread titled "[CFCDEV] Using
object "getters" after form validation fails" talks about having invalid
data - specifically with a User object.
What I do is this:
<cfscript>
var User=getUserService().newUser();
User.setMemento(form);
User.validate(Username,Password);
</cfscript>
<!--- if there are no validation errors, load user using username and
password --->
<cfif not User.hasValidationErrors()>
<cfset User.loadFromLogin() />
<cfelse>
<cfset getSystemMessages().appendErrors(User.getValidationErrors()) />
</cfif>
<!--- pass back system messages (even if it is empty the view will know what
to do) and user object (so that I can repopulate the form with the bad data)
--->
<cfset arguments.event.setValue('SystemMessages', getSystemMessages()) />
<cfset arguments.event.setValue('User', User) />
The validator and DAO and whatever else is neatly composed within the User
object. The controller and service do very little leaving the hard work to
the User object. That way the domain model is NOT anemic (rich?).
Thats just what I do. There are a million good ways to go about it - each
with its own benefits and constraints.
Good luck.
Baz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---