jsonCase argument in RequestContext.renderData

Hey guys,

It seems the jsonCase argument in the RequestContext.renderData has been removed in CB3.5.
I kind of miss it because some of the JQuery UI widgets use JSON with lower case labels and CB3.5’s renderData(type=“JSON”) returns JSON with upper case labels.

So where JQuery normally would do stuff natively like for instance the autocomplete widget, I now have to do extra mapping…

Example:
autocomplete expects JSON format = [{“id”:“someID”,“label”:“someLabel”,“value”:“someValue”},{“id”:“someOtherID”,“label”:“someOtherLabel”,“value”:“someOtherValue”},…]
but ColdBox 3.5 returns = [{“ID”:“someID”,“LABEL”:“someLabel”,“VALUE”:“someValue”},{“ID”:“someOtherID”,“LABEL”:“someOtherLabel”,“VALUE”:“someOtherValue”},…]

So where normally following would do:

$( “#branchCity” ).autocomplete({
source: ‘#event.buildLink(“ajax/autoCompleteCities”)#’,
minLength: 2
});

I now have to map my upper case variables to lower case:

$( “#branchCity” ).autocomplete({
source: function(request, response){
$.getJSON(
#event.buildLink(“ajax/autoCompleteCities”)#’,
{term: request.term},
function(data){
response( $.map( data, function( item ) {
return {
id: item.ID ,label: item.LABEL, value: item.VALUE
}
}));
}
);
},
minLength: 2
});

As you can see, a pretty huge difference… Any reason for this change?

In previous versions we did our json manually And had much more control but to the expense of performance. Now we use native cf functions. You can still use this json plugin as it is in forgebox. Just download it and use it.

Luis Majano
CEO
Ortus Solutions, Corp
Toll free phone/fax: 1-888-557-8057
Mobile: 909-248-3408
www.ortussolutions.com
www.coldbox.org

Thanks for the reply Luis.

Performance is always a good enough reason, specifically with the amount of requests our servers have to deal with on a daily basis.
In that case I will leave it as it is and give the extra work to Javascript on the client side. It is always nice when the client’s computing power takes some of the strain off our servers.

P.S. ColdBox 3.5 is working wonderful for our projects and I would encourage everybody to start using and testing it. We have found no issues so far, except for the missing return statement in the onRequestStart function in the Application.cfc when starting a new project in CFBuilder, and that is an easy fix; just add .

Cheers,
Tom

Luis,

Are there instructions on how to use the non core version to override the core version, because things like RenderData would be using core not plugins?

I too find myself in this problem, and as long as we can use or override the core then all is good but if we can’t then its too much pressure and a work around.

Yes

There is a setting called coldboxextensionslocation where toucan override core plugins. Just drop it there