modulecoldfusioncoldbox

How to access the event arguments passed to a ColdBox module?


I have a view in my ColdBox application that is calling a module handler within the view like this:

#runEvent( event="mymodule:home.index" )#

Now I want to pass arguments to the module, so I changed the call to this:

#runEvent( event="mymodule:home.index", eventArguments=moduleArgs )#

Though unfortunately I don't seem to have access to the passed arguments within the module's event handler. I've dumped rc and prc, but they only contain variables I've set in the main event handler and the event argument doesn't seem to provide a method to return the passed arguments. The documentation about module event executions unfortunately doesn't provide any information about this.

Also, I realized calling event.getCurrentModule() within the module returns an empty string. I would have expected the module's name.

So, how can I access the arguments passed to a module? Is runEvent() the right function for this? Did I miss a module config setting?


Solution

  • You can define arguments in your function like this

    function index(event, rc, prc, isRender=false) {
      writedump(arguments);
      abort;
    } 
    

    See the ColdBox runEvent() documentation.