Issues with Coldbox

I have run into some issues with Coldbox that I don’t quite understand. I’d like to post my problems in the hopes that someone can help, or I can help someone else.

UPDATE: I found the solution. It still revolves around SES, just like I thought. I noticed one of my other forms was behaving itself, so I looked closer for the difference, and found it.

Here’s the working form action: #getSetting(’sesBaseURL’)#/

And the non-working form action: #getSetting(’sesBaseURL’)#

Yep, I was mising the / at the end. That’s what threw off my SES routing. Oh well! Movin’ on…

Consider this simple view:

<form action=”#getSetting(’sesBaseURL’)#” method=”post” name=”emailForm”>
<input type=”hidden” name=”event” value=”#rc.xehDoit#”>
Enter your email: <input type=”text” name=”email” />
<input name=”submit” type=”submit” value=”submit” />
</form>

Looks simple enough. It’s just an email form. The action uses a SES path.

That puppy submits to this handler:

<cffunction name=”reqUsername” access=”public” returnType=”string” output=”false”>
<cfargument name=”Event” type=”coldbox.system.beans.requestContext”>
<cfscript>
var rc = event.getCollection();
var email = rc.email;
var result = “”;
var loginService = getColdboxOCM().get(‘loginService’);

dump(email);
abort();

if(not len(email) or not isValid(“email”, trim(email))){
// dump(email);
//abort();
getPlugin(“messageBox”).setMessage(“Warning”, “Enter a valid email”);
setNextRoute(“Login/frmUsername”);
//setNextEvent(“Login.frmUsername”);
}

else{
result = LoginService.reqUsername(email);
arguments.event.setValue(“retUsername”, result);
arguments.event.setView(“dspUsername”);
}
</cfscript>
</cffunction>

I left the dumps in there so you can see how to dump data like your usual <cfdump>, <cfabort>

The first problem I had was, when I changed my setting so the app uses SES routing, it broke the handler that processes this form. After a day or two of fumbling around in the docs, I found the problem. Apparently you need to use setNextRoute() when using SES routing. You can see where I’ve commented out my old code:

//setNextEvent(“Login.frmUsername”);

She was throwin’ errors at me. I added the setNextRoute(“Login/frmUsername”); bit and it worked fine.

Ok, so what’s the problem? When I dump it, why does my email variable contain a list of the emails entered?

wt@wtomlinson.com,wt@wtomlinson.com

I’ve yet to figure this out.

No comments yet

Leave a reply