The MVC pattern allows views to interrogate data from the model as provided
by controllers, as long as they don't alter the state of the model. When I
use a helper as an adapter to a service bean for views, I do not have the
helper expose the service methods that alter the state of the model or
system. Controllers are of course free to alter the model and system state,
so I give them direct access to the service beans they need.

I finally got my code up on GitHub last night. You can find it at
http://github.com/boomfish/mgsecurity. I made some tweaks to the files
before making my first commit so there likely to be some inconsistencies
with the code and documentation. Let me know if/when you find issues that
need addressing and I'll work on fixing them when I can. Expect my fixes to
be slow going at first; this is my very first Git project, and in fact I
don't yet understand half the commands I used to upload the code to GitHub.

PS. My example code is very much a work in progress. Feel free to pick ideas
from it (or conversely, criticize ideas in it) but the code itself is
alpha-quality at best.

Cheers,
-- Dennis

On Mon, Jun 7, 2010 at 6:34 AM, steve82 <[email protected]>wrote:

> Hi Dennis,
>
> the longer I think about my problem, the more I think it would really
> be better to write a SecurityService.cfc and put that to my other
> models instead of using a helper. Your technique of bean injection
> into helpers sound interesting. But isn't having an adapter (the
> helper) which can be used to access the model (bean injected into
> helper) in a view somehow circumventing the whole MVC pattern?
>
> I would like to see your login example code from NCDevCon, please let
> us know when it's up on GitHub.
>
> Cheers,
>
> -- Steve
>
> On 4 Jun., 16:56, Dennis Clark <[email protected]> wrote:
> > +1 on the idea of using a service bean instead of a helper for
> implementing
> > login logic. Helpers were designed to be used within views, not
> controllers.
> >
> > Although it's not documented on the Wiki, the latest release of
> Model-Glue
> > supports bean injection into helpers. This means that if you want to
> expose
> > your login bean's logic in a view, you can create a login helper CFC and
> > inject your login service bean into it. The helper then acts as an
> adapter
> > to expose the functionality of the bean that's relevant to views.
> >
> > I use this very technique in the Model-Glue login example code I used in
> my
> > recent NCDevCon presentation. I haven't released the code yet, but am
> > planning to put it up on GitHub this weekend. I'll post something on this
> > list when it's out.
> >
> > Cheers,
> >
> > -- Dennis
> >
> > On Wed, Jun 2, 2010 at 2:32 PM, David J Henry <
> >
> > [email protected]> wrote:
> > > Steve,
> >
> > > Did you start with the skeleton ModelGlue3 project?  What triggers the
> > > call to your security controller in ModelGlue.xml?  You say "getting
> > > some errors lately".  Did this error start after some kind of change?
> >
> > > Personally I might put a function like IsLoggedIn() in a service
> > > component somewhere in my model like /model/SessionService.cfc or /
> > > model/services/SecurityService.cfc for example.  I would use
> > > ColdSpring and Bean Injection to make this service accessible from my
> > > controller in the beans scope.
> >
> > > See
> > >http://docs.model-glue.com/wiki/HowTos/HowToUseBeanInjection#BeanInje.
> ..
> > > for more about Bean Injection
> >
> > > I don't know enough about helpers to know why the helper scope
> > > wouldn't be available on first request.  If you can provide some more
> > > details about your application I will try to reproduce the problem.
> >
> > > ...or you could just come in to work extra early and hit the app
> > > before your co-workers get there x)
> >
> > > Cheers,
> > > ~David
> >
> > > On May 31, 4:33 am, steve82 <[email protected]> wrote:
> > > > Hi everybody,
> >
> > > > I've build a Model-Glue application for my firm and we're getting
> some
> > > > errors lately. We are currently using Model-Glue version 3.1.299. The
> > > > error appears every morning. So I assume, that this is the time when
> > > > Model-Glue first loads up for that day and stores a copy of itself in
> > > > the application scope.
> >
> > > > The following error message appears:
> >
> > > > Oops!
> >
> > > > Message  Element LOGINHELPER is undefined in a Java object of type
> > > > class [Ljava.lang.String;.
> > > > Detail
> > > > Extended Info
> > > > Tag Context  C:\Inetpub\wwwroot\office\controller\Security.cfc (42)
> > > > C:\Inetpub\wwwroot\lib\cf\frameworks\mvc\modelglue\ModelGlue\gesture
> > > > \eventrequest\EventContext.cfc (326)
> > > > C:\Inetpub\wwwroot\lib\cf\frameworks\mvc\modelglue\ModelGlue\gesture
> > > > \eventrequest\EventContext.cfc (253)
> > > > C:\Inetpub\wwwroot\lib\cf\frameworks\mvc\modelglue\ModelGlue\gesture
> > > > \eventrequest\phase\Invocation.cfc (91)
> > > > C:\Inetpub\wwwroot\lib\cf\frameworks\mvc\modelglue\ModelGlue\gesture
> > > > \eventrequest\EventContext.cfc (180)
> > > > C:\Inetpub\wwwroot\lib\cf\frameworks\mvc\modelglue\ModelGlue\gesture
> > > > \ModelGlue.cfc (243)
> > > > C:\Inetpub\wwwroot\lib\cf\frameworks\mvc\modelglue\ModelGlue\gesture
> > > > \ModelGlue.cfm (83)
> > > > C:\Inetpub\wwwroot\lib\cf\frameworks\mvc\modelglue\ModelGlue\gesture
> > > > \ModelGlue.cfc (243)
> > > > C.\Inetpub\wwwroot\office\index.cfm (50)
> >
> > > > The code in Line 42 in our Security Controller just tries to call a
> > > > method from the LoginHelper.cfc that is stored in the helpers
> > > > directory:
> >
> > > > <cfif NOT helpers.LoginHelper.isLoggedIn(sid)>
> > > >   <cfset arguments.event.addResult("notLoggedIn") />
> > > > <cfelse>
> > > >   <!--- creation of user object goes here --->
> > > > </cfif>
> >
> > > > It looks to me that Model-Glue tries to access the helpers scope but
> > > > it's not initialized yet - instead CF treats it as a normal string
> > > > variable.
> >
> > > > Any ideas about how this problem and how one could prevent this from
> > > > happenig? Telling my colleagues that they have to be more patient in
> > > > the morning when the app first load up doesn't work - i already tried
> > > > that :-)
> >
> > > > Many thanks,
> >
> > > > Steve
> >
> > > --
> > > Model-Glue Sites:
> > > Home Page:http://www.model-glue.com
> > > Documentation:http://docs.model-glue.com
> > > Bug Tracker:http://bugs.model-glue.com
> > > Blog:http://www.model-glue.com/blog
> >
> > > You received this message because you are subscribed to the Google
> > > Groups "model-glue" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<model-glue%[email protected]>
> <model-glue%[email protected]<model-glue%[email protected]>
> >
> > > For more options, visit this group at
> > >http://groups.google.com/group/model-glue?hl=en
>
> --
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog
>
> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<model-glue%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en
>

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" 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/model-glue?hl=en

Reply via email to