[Coldbox 3.1] SES Route Execution in Modules

Hey folks,

I’m working on a new module and am having an issue with SES route execution.
My module name is ‘products’ and I generated it using the ColdBox Builder extension. I have also added the following to my host application routes:

addModuleRoutes(pattern=“products”,module=“products”);

All is good and I can access the module entry point by:

http://local.myapp.com/products:home/index

or

http://local.myapp.com/products

In my Home.cfc handler I have two functions - index() and add(). Both of these execute when I access like so:

http://local.myapp.com/products:home/index
http://local.myapp.com/products:home/add

According to the SES Default Route execution docs on the wiki - http://wiki.coldbox.org/wiki/Modules.cfm I should be able to access the add() method by:

http://local.myapp.com/products/add

however, this fires just takes me to the index function and I see the following the tracer log:

Invalid Module Event Called: products:add.index. The module: products is not valid. Valid Modules are: partners,products

This is what I have for route definitions within my ModuleConfig.cfc

routes = [

// Module Entry Point
{pattern="/", handler=“Home”,action=“index”},

// Convention Routes
{pattern="/:handler/:action?"}

];

Any idea why I can’t resolve /products/add/ ? The docs indicate that this should work.

Thanks.

Nolan

You still need the handler name.

http://local.myapp.com/products/handler/add

Thanks Andrew. I was able to get that to work.

That creates a bit of a messy SES URL. i.e

http://local.myapp.com/products/home/add … with home being the name of the handler. in my mind though, the name of the module - products - is routed to the entry point products:home.index , therefore you would think that products/add would map to the same entry point and an action function called add.

I was able to get /products/add to work by adding this module route:

routes = [

// Module Entry Point

{pattern="/", handler=“Home”,action=“index”},

{pattern="/add", handler=“Home”,action=“add”},

// Convention Route

{pattern="/:handler/:action?"}

];

to me it seems like something like products/add should just work by convention given the entry point is effectively products/index.

Thanks.

Nolan

No you are right, but the thing is that the default

{pattern="/:handler/:action?"}

is probably kicking in.