Monday, September 10, 2007

Common Model-Glue "Newbie" Mistake

In short: forgetting to "wire" the message broadcasted by your event to the function in your controller. I still do this on occasion which prompted me to post it. The longer version: You have a an event defined as follows:
<event-handler name="GetUsersForm">
  <message name="getRolesList" />
  <message name="getSytelineUsersBySiteID" />
  <message name="getUsersBySiteID" />

  <view name="body" template="frmUsers.cfm" />
You have "getRolesList", "getSytelineUsersBySiteID" and "getUsersBySiteID" defined in your controller. However, when you call the event, you don't get any of the data you expect to see there. The gotcha is "wiring" the broadcasted message to the function in the controller as follows:
<controller name="ApplicationController" type="LabelGeneration.controller.ApplicationController">
 <message-listener message="OnRequestStart" function="OnRequestStart" />
 <message-listener message="OnQueueComplete" function="OnQueueComplete" />
 <message-listener message="OnRequestEnd" function="OnRequestEnd" />

 <message-listener message="getSitesList" function="getSitesList" />
 <message-listener message="getRolesList" function="getRolesList" />

 <message-listener message="getSytelineUsersBySiteID" function="getSytelineUsersBySiteID" />
 <message-listener message="getUsersBySiteID" function="getUsersBySiteID" />
 <message-listener message="addUser" function="addUser" />
 <message-listener message="deleteUser" function="deleteUser" />
// //]]>