Hi Peter and Kurt
Thanks for the responses. I should have explained that I am
refactoring some business objects to be more intelligent i.e. fat-bean/
thin-service VS thin-bean/fat-service. I thought more people where
moving in this direction (Kurt / Peter it sounds like you guys
haven't). Up until now I have taken the approach of having my beans
pretty much be just data holders with getters / setters and then the
service layer does the rest ("thin bean / fat service concept). This
has worked well for me to date but I've recently created one object
where I think it should be able to validate itself (I am completely
changing the way I process form validation, persistence etc). The
object is what I call a formProfile object (there will be 1 per form).
In brief: the form submits to M2, which populates the appropriate
formProfile bean with everything set to strings. The bonus is that I
can poke the formProfile bean into the Session scope so when the form
is displayed again I can populate it easily. So now I'm at the point
where I want it to be validated. It makes sense that the formProfile
object should validate itself and return an array of errors if found.
I could do this validation in the Service layer but it just doesn't
make sense. I guess I'm still on the fence with fat-bean/thin-service
VS thin-bean/fat-service. Perhaps a mix of the 2 is acceptable as
well?
@Peter: I was reading this post (http://www.web-relevant.com/blogs/
cfobjective/index.cfm?mode=entry&entry=CC41749D-BDB9-5320-
E6CB3B1A3AA11799) and notice you were advocating thin-bean/fat-service
back in 2006. Also in another recent post (http://groups.google.com/
group/mach-ii-for-coldfusion/browse_thread/thread/d156ebb48ee378cd) on
the M2 forum you mentioned similar practice. So I assume you still
find this the best solution for you?
@Kurt: do you follow the thin-bean/fat-service pattern?
Cheers
Matthew
On Dec 17, 3:29 am, Kurt Wiersma <[email protected]> wrote:
> I agree with Peters solution however there is a way to use event-bean to get
> around this. You can use a listener call before the event-bean command to
> get a Person cfc from your service/ColdSpring setup and place it in the
> event object.
>
> <notify listener="PersonListener" method="getPerson" resultArg="person" />
> <event-bean name="person" type="foo.person" reinit="false" />
>
> Notice the use of reinit=false and the user of the resultArg in the notify
> command. This will tell Mach II to use the instance of the person object
> that is in the event object before populating the bean. You can also use the
> new call-method command in 1.8 to directly call your service layer instead
> of using the notify command.
>
> --Kurt
>
> On Wed, Dec 16, 2009 at 2:21 AM, Peter J. Farrell <[email protected]> wrote:
>
> > Well, you shouldn't be using ColdSpring to instantiate your transient
> > beans. Personally, I'd pass my Person bean to a validatePerson() method in
> > the PersonService instead of calling validate() on the bean directly. It
> > will give you much flexibility in the term.
>
> > .pjf
>
> > Matthew said the following on 12/15/2009 09:25 PM:
>
> > Hi all
>
> > I'm playing around with event-bean. I have everything working when a
> > use event-bean to populate my bean however I'm now writing the validate
> > () method on my bean which needs to call the Service/Dao/Gateway to
> > check some of my bean data against the DB. The problem is that because
> > the event-bean type="" attribute can only be pointed directly at the
> > CFC then it isn't instantiated by ColdSpring so none of the
> > dependencies (e.g. Service) are initialised. Does anyone have a
> > solution for this? I've had a dig in M2 and can see that it calls the
> > init() method on the bean so do I need to have all my dependency stuff
> > hard coded in here and therefore can't use ColdSpring?
>
> > Cheers
> > Matthew
>
> > --
>
> > [image: The Harmonious
> > Programmer]<http://feeds.feedburner.com/%7Er/TheHarmoniousProgrammer/%7E6/1>
>
> > *Peter J. Farrell*
> > Email: [email protected] | p...@maestropublishing
> > Blog: The Harmonious Programmer <http://blog.maestropublishing.com>
> > Twitter/Identi.ca: @maestrofjp
>
> > --
> > You received this message because you are subscribed to Mach-II for CFML
> > list.
> > 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/mach-ii-for-coldfusion?hl=en
> > SVN:http://greatbiztoolsllc.svn.cvsdude.com/mach-ii/
> > Wiki / Documentation / Tickets:
> >http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/
>
>
>
> TheHarmoniousProgrammer.1.gif
> 64KViewDownload
--
You received this message because you are subscribed to Mach-II for CFML list.
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/mach-ii-for-coldfusion?hl=en
SVN: http://greatbiztoolsllc.svn.cvsdude.com/mach-ii/
Wiki / Documentation / Tickets:
http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/