Building first Module - Routing Issue

Hi guys,

I’ve been working on taking an existing Coldbox app and converting into a module. I’ve been able to get the basic loading and config working however i’m having issues getting the routing to work.

Here is my setup.

In the host application I’ve added the following moduleRoute:

addModuleRoutes(pattern="/connect",module=“connect”);

When someone comes to the site they will hit a URL like:

www.mysite.com/connect/foo/id1/id2/id3/

In my module config I have this route:

{pattern="/foo/:id1/:id2/:id3/",handler=“foo”,action=“Login”},

For reference (and not sure if it’s useful to this question) my module entry point is: this.entryPoint = “connect:home.index”;

Now…the routing appears to work and it hits the Login action…

function login(event){
var rc = event.getCollection();
//writeDump(event.getCurrentAction());abort;
//Delete login Information
sessionService.clearAll();
event.setView(‘foo/login’);

}

However, when it tries to render the view it redirects to my invalid event handler. If I uncomment the dump it also only displays :id1

I’m at a bit of a loss here to determine what is messed up. Hoping someone can point me in the right direction.

Thanks all!

Nolan

Nolan,

I see the same issue as you I think. I setup a module but can’t seem to have ColdBox respect the SES route convention of “:handler/:action?” within the module. This route, however, works: {pattern=":action",handler=“myHandler”}.

Perhaps one of the other module wizards knows what config error I may have made? I’ve looked at the source for the public modules and everyone seems to be using explicit URLs like “relax:home.index”.

Thanks,

Aaron Greenlee
http://aarongreenlee.com/

The default handler/action is for the parent. A module needs to define one if it wanta to use it in the module.

Thanks Aaron, I was able to get the module working by adding {pattern=":action",handler=“myHandler”} to my module routes.

I’m now getting random errors occurring that I think may have something to do with using SES routes and modules. The first one is…

Framework Initialization/Configuration ExceptionError Type: Expression : [N/A]

Error Messages: Cannot access array element at position 3.
The array has 1 indexes. Valid positions are from 1 to 1.

Tag Context:
ID: CF_CFPAGE
LINE: 481
Template: /Library/WebServer/Documents/guardly-platform/common/frameworks/coldbox/system/interceptors/SES.cfc
ID: CF_TEMPLATEPROXY
LINE: 399
Template: /Library/WebServer/Documents/guardly-platform/common/frameworks/coldbox/system/web/services/ModuleService.cfc

And the second one is:

Framework Initialization/Configuration ExceptionError Type: SES.InvalidModuleName : [N/A]

Error Messages: Error loading module routes as the module requested ‘connect’ is not loaded.
The loaded modules are:

Tag Context:
ID: CFTHROW
LINE: 413
Template: /Library/WebServer/Documents/guardly-platform/common/frameworks/coldbox/system/FrameworkSupertype.cfc
ID: CF_UDFMETHOD
LINE: 179
Template: /Library/WebServer/Documents/guardly-platform/common/frameworks/coldbox/system/interceptors/SES.cfc

The weird thing is that when these errors occur when i’m not even accessing the module. i’m in a completely separate part of the app.

Does anyone have any idea what might be going on?

Thanks

Nolan

Ate you using 3.1 or nightly? Also are you using autoreload for modules

Hi Luis,

I’m using 3.1 and modules auto reload is set to true (in development environment)

Thanks.

Nolan

Ahh ok I think mike mckellip reported this and contributed a fix and it is in the development branch. It deals with the autoreload flag. I would recommend either turn it off or update to development.