Listing handlers in my module

Hi Gang,

In my journey of learning ColdBox I have started my first application module.

I copied the contents of {app_root}/views/main/index.cfm into the {app_root}/module_app/views/home/index.cfm file.
(The contents of which are “basically” stolen from the sample application)

To my surprise the following code provides a list of handlers from app_root not my new module.

<div class="list-group">
	<cfloop list="#getSetting("RegisteredHandlers")#" index="handler">
		<a href="#event.buildLink(handler)#" class="list-group-item list-group-item-action d-flex gap-2 py-3" title="Run Event">
		    <div class="rounded-circle flex-shrink-0 text-success px-1">
		        <i class="bi bi-play-btn" aria-hidden="true"></i>
		    </div>
		    <div class="d-flex gap-2 w-100 justify-content-between">#handler#</div>
	    </a>
	</cfloop>
</div>

My 2 questions are (please) :

  1. Why is it so? - why is the app_root handlers being shown in the module?
  2. How do I go about producing a list of the handlers that are defined in my module (module_app)?

As always - thanks very much!

For your question #2 : Have you tried using the getModuleSettings instead ?

/**
 * Get a module's settings structure or a specific setting if the setting key is passed
 *
 * @module The module to retrieve the configuration settings from
 * @setting The setting to retrieve if passed
 * @defaultValue The default value to return if setting does not exist
 *
 * @return struct or any
 */
any function getModuleSettings( required module, setting, defaultValue )

See docs here if that can help :

1 Like