Output from runEvent()

Shouldn't I be able to do this?

<cfsaveContent variable="userAddressList">
  <cfset runEvent("user.userAddress.list")>

<cfset event.setValue("userAddressList",userAddressList)>
<cfset event.setView("user/userEditor")>

Now in my userEditor.cfm I want to be able to display the contents
returned from the runEvent(). I see the userAddressList in the request
collection but the value states "N/A".


runEvent() does not return output of views. It returns output from event handlers. If you want to store the output of an event, this is much different and hard, why not just render a view on demand?

Thanks Luis. It is for a parent child relationship where I already had
the events and views for the child built, and while on the edit form
for the parent, wanted to display the child records for that parent on
the form.

A dashboard is another good example where you may want to call several
events that render a view on their own elsewhere in the app, but now
you want to run them all at the same time to capture the output for a
dashboard view.

Does this mean if I do runEvent(client.configClient) and runEvent(user.configUser), data put into the even by those 2 events is available to me in the evnt I am calling runEvent() from?


Yes Dan,

If you call event A and event B from event C, all the data that A and B place into the event object will be available in event C. This is called event chaining. I don’t know if I am a fan of it, but it is a capability that can be leveraged. However, please be careful when doing this, because it can get out of hand pretty quickly. I suggest maybe putting this functionality in a helper plugin or encapsulated somewhere else. However, it is very common practice.

You can also do things where you can execute runEvent() and make that event get data and actually return a view contents. Example:

... Get Data Here....

<cfreturn renderView(‘myView’)>

This simple even, will just call the model, get data and then return a rendered view.