--
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 model...@googlegroups.com
To unsubscribe from this group, send email to
model-glue+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en
There are six built-in event-handlers that are commonly used:
modelglue.onApplicationStart
modelglue.onSessionStart
modelglue.onSessionEnd
modelglue.onRequestStart
modelglue.onRequestEnd
modelglue.onQueueComplete
Each of these event-handlers broadcasts a message of the same name
without the "modelglue." prefix, so for example, the
modelglue.onRequestStart event-handler broadcasts an onRequestStart
message.
So if you wish, you can just add a message-listener for the
appropriate message broadcast -- see the page that Todd referenced for
examples of this.
If you prefer, however, you can define the relevant event-handler as
Dan described, and broadcast whatever messages you would like.
The first five events listed should be intuitive enough as to when
they are invoked -- the sixth, onQueueComplete, is fired after all the
views for a request have been queued, and before they are rendered.
Do note that Model-Glue does not have any support for CF's
onApplicationEnd event, so you will need to add this to your app's
Application.cfc file if you wish to use it.
--
Ezra Parker
sessionStart = true />
Marc
--
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 model...@googlegroups.com
To unsubscribe from this group, send email to
model-glue+...@googlegroups.com
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