RE: [coldbox:11780] jsonp

I love pizza! Hopefully it’s peperoni.

~Brad

Luis,

Quick questions about the JSONP code. The jsonp callback is almost always defined in the request by setting a callback attribute in the query string. Is there a way to keep me from always having to specify the jsonCallback attribute each time?

Given that the callback will almost always be the callback param in the request context, can we have it defaulted to the value of the callback passed into the request context?

event.renderData(type=‘jsonp’, data=myData, jsonCallback=rc.callback);

vs

event.renderData(‘jsonp’,myData);

While the former is definitely workable, I would prefer to avoid having to use the longer format EVERY time.

Another thought, most JSONP services fallback to JSON if no callback is provided. Instead of having that if/else code in every handler function, would it make sense to have that fallback happen in the RequestContext or the Utilities plugin?

Anyone else have a comment/dissenting opinion?

Cheers,
Ben

I have added the fallback as I think that is a good idea. As for taking the callback from the collection, that to me is more of an assumption than anything. I think that with the current implementation you can do what you want with a request context decorator and using your defaults instead of putting that in the core.

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano