Hello everyone,
first of all, I dont know if this should be in the java or the jsp forum. I put it here since is a web related question.
I am making a report module for a web page using java. For this I will use a jquery plugin called datatables (I'm not sure if it's allowed to link to it). The point is that I need to generate a json string dynamically in order to get my reports.
The problem is that along with my data I will also have to send some anonymous functions in the json. I have used some libraries to convert java objects to a json string but nothing on how to send a function.
The jsons will look something like this:
{
"aoColumns": [
{ "sTitle": "Column 1" },
{ "sTitle": "Column2" },
{ "sTitle": "Column3" },
{ "sTitle": "Column centered",
"sClass": "center" },
{"sTitle": "Column rendered",
"sClass": "center",
"fnRender": function(obj) {
var sReturn = obj.aData[ obj.iDataColumn ]; if ( sReturn == "A" ) {
sReturn = "<b>A</b>";
}
return sReturn;
}
}
]
}
I know I can generate it manually as a string, but that seems quite complex and I would like to keep that as a las resort.
Anyone knows a library that can generate javascript functions from java?
Thank you for any help you can provide me. This place looks quite nice btw