i want to return a JSON from primefaces to d3 with the help of d3.json,but it is throwing error.
My primefaces bean,
@ManagedBean
@SessionScoped
public class JsonBean implements Serializable {
private static final long serialVersionUID = 1L;
JsonExample jse=new JsonExample();
public void prepareChartDate() {
RequestContext reqCtx = RequestContext.getCurrentInstance();
reqCtx.addCallbackParam("chartData",jse.createJson());
}
}
jse.createJson() will give the json as
{"A":10,"B":20,"C":30,"weekdays":["Sun","Mon","Tues"]}
and the d3js code which i m calling in .xhtml file is
<script src="http://d3js.org/d3.v3.js"></script>
<script>
var data;
d3.json("#{jsonBean.prepareChartDate()}",function(error, json) {
if (error) return console.warn(error);
data = json;
console.log(data);
//console.log("hello");
});
</script>
when i m printing in the console it is giving error in firebug.