Marc,
I'm not entirely clear as to where things stand for you at this point
-- you sent a message about 24 hours ago that seemed to state you had
sorted out the onSessionStart issue, but then this latest message
appears to indicate that there is still a problem (specifically, the
"if it's not being triggered by CF's
> implicit event - onSessionStart" portion). Is this working for you?
>From this latest message, I think that there is a bit of confusion as
to how CF's application lifecycle events are handled by Model-Glue. I
would recommend going with the simplest approach here, which is to
define a message-listener in your XML config, along with a
corresponding function in your controller.
The message-listener should look like this:
<message-listener message="onSessionStart" function="onSessionStart" />
Or if you prefer, you can omit the "function" attribute, as it is
optional if the function name is the same as the message name:
<message-listener message="onSessionStart" />
Then in your controller, your function should be named "onSessionStart":
<cffunction name="onSessionStart" access="public" output="false">
It is important that you do NOT alter the onSessionStart function in
Application.cfc (the same goes for onSessionEnd) -- it should look
like this:
<cffunction name="onSessionStart" output="false">
<!--- Set flag letting MG know it needs to broadcast onSessionStart
before onRequestStart --->
<cfset request._modelglue.bootstrap.sessionStart = true />
</cffunction>
(In the original version, there is a call to the invokeSessionEvent
function that is commented out -- you do not need this for normal
usage of the onSessionStart event.)
You do NOT need to define a modelglue.onSessionStart event-handler in
order for this to work. As a matter of fact, if you do define this
event-handler, you must also define the onSessionStart message within
it -- otherwise, this message will not be broadcast, as you will be
replacing the internal modelglue.onSessionStart event-handler with
your version, and therefore its message broadcast will not occur.
Finally, I wanted to mention a couple of things regarding the
controller code you posted. First, these lines should not be in your
controller:
<!--- Set flag letting MG know it needs to broadcast onSessionStart
before onRequestStart --->
<cfset request._modelglue.bootstrap.sessionStart = true />
As I mentioned above, this code needs to be in the onSessionStart
function of Application.cfc, and it does serve any purpose in the
onSessionStart function of a controller.
Also, I would recommend using a different approach for accessing
services in controllers -- currently, you have this:
<cfset
localData.utilityService=APPLICATION["_modelglue"].getBean("UtilityService")>
In Model-Glue 3, the best practice is to use the "beans" scope for
this task -- please see this wiki page for details:
http://docs.model-glue.com/wiki/HowTos/HowToUseBeanInjection
After adding the UtilityService bean to the controller's XML config or
metadata, you can reference the service like so:
<cfset session.locale = beans.UtilityService.convertAccLanToLocale()>
Although this would be my strong recommendation, if you want to use
the getBean() method instead, then I would definitely suggest using
the getModelGlue() method to retrieve the framework rather than a
direct reference to the application scope:
<cfset localData.utilityService = getModelGlue().getBean("UtilityService")>
Please let me know if any of this is unclear, or merits further explanation.
--
Ezra Parker
On Mon, Jan 17, 2011 at 2:52 AM, marc <[email protected]> wrote:
> @Chris
>
> I tried this:
>
> ===== snip ===
> Then I tried with onRequestStart and this didn't work either - until I
> changed the message listener from
>
> <message-listener message="modelglue.onRequestStart"
> function="onRequestStart" />
>
> to
> <message-listener message="onRequestStart"
> function="onRequestStart" />
>
> Then I got to the <cfdump> I put in it after a page refresh.
>
> ===== snip ===
>
> Which seems to be just the opposite of what you suggest. Unless I
> misread I understand from your post that in order to fire on the
> implicit Coldfusion generated events (onRequestStart etc) I should use
> <event-handler name="modelglue.onSessionStart">.
>
> Btw why would use <message-listener message="onSessionStart"
> function="onSessionStart" /> if it's not being triggered by CF's
> implicit event - onSessionStart?
>
> Marc
>
> On Jan 16, 10:24 pm, Chris Blackwell <[email protected]> wrote:
>> If you're setting up listeners in a controller just use onSessionStart (not
>> modelglue.onSessionStart)
>>
>> <message-listener message="onSessionStart" function="onSessionStart" />
>>
>> if you want an event-handler to be fired onSessionStart (or any of the other
>> implicit events then use modelglue.onSessionStart
>>
>> <event-handler name="modelglue.onSessionStart">
>>
>> Chris
>>
>
> --
> 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