I've been using model-glue for a while and have started to wonder how
other people would structure their event handlers, message listeners
and controllers. Here's the example problem and 2 different way's
I've figured out how to solve it.
The scenario is a typical user edit form. We'll need to lookup a user
record and populate 2 select boxes with queries, one for department
and one for region.
<event-handler name="user.edit">
<broadcasts>
<message name="needUser" />
<message name="needUserDepartments" />
<message name="needUserRegions" />
</broadcasts>
<results />
<views>
<include template="/user/edit_form.cfm" />
</views>
</event-handler>
In the Controller each of the messages will call a function that will
load the proper query into the event.
The 2nd way I've figured out how to do it is:
<event-handler name="user.edit">
<broadcasts>
<message name="needUserEditData" />
</broadcasts>
<results />
<views>
<include template="/user/edit_form.cfm" />
</views>
</event-handler>
Where the user edit function will look like:
<cffunction name="user_edit_form">
<cfargument name="event" />
<cfset event.setValue('userObj', transfer.get('user',
event.getValue('user_id'))>
<cfset event.setValue('regionsQry', transfer.list('regions'))>
<cfset event.setValue('departmentsQry',
transfer.list('departments'))>
</cffunction>
I can see advantages and disadvantages to each way, but was wondering
what the community prefers and why.
--
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