Adding event variables to ModelGlue.xml
When using Joe Rinehart's Model-Glue framework, I noticed a few people that come from using fusebox based apps were a bit confused at how you would set either application wide variables, or fuse-action (i.e. event) specific variables (such as xfa's). In the definition of MG itself there isn't something blatantly obvious, so how would you set, for example, the section variable that each of the event-handlers belongs to (for the title for example)?
In the controller, I created a function called setValue, this function loops through any arguments you pass to them creating event values for them:
<cfset arguments.event.setValue(arg, stArguments[arg])>
I can then set an event constant in the event-handler, by broadcasting the following message:
This means that in my view code I can get the section variable as follows:
#ViewState.getValue("xfa.section")#
In my next post, I shall set some application wide variables, and show you how to access them in a similar manner.
EDIT: Andy Jarett has just pointed out something (which should have been as plain as the nose in my face) that instead of having to do the above, you can simply do the following for each include:
<include name="body" template="dsp_body.cfm">
Which is obviously the easier way of doing it (if you bother to read the documentation, which I didn't).