While I definitely concur that login logic is a model concern, I do
not agree with the assertion that helpers should only be used in views
and not in controllers. From my perspective, the intention of the
helpers "scope" is to provide a way to easily access UDFs in either
views or controllers.

As an arbitrary (and perhaps contrived) example, I could see using a
helper in a controller to format/massage data in the event before
handing it off to a service, or using it to populate an object via a
call to makeEventBean().

--
Ezra


On Fri, Jun 4, 2010 at 7:56 AM, 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#BeanInjection
>> 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]
>> 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

-- 
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