我想使用PF requestcontext在托管bean中调用javascript函数。该功能似乎没有被执行。想知道我是否正确称呼它?我正在使用PF 3.5
<script type="text/javascript">
function renderChart(divId, chartType, chartTitle, chartData, categories) {}
</script>
public void populateChart1() {
String _LOC = "[Db1002: populateChart1]";
System.out.println(_LOC + "1.0");
.
.
.
.
HashMap _m_js = createJSONString2(_l);
String _cat = (String) _m_js.get("CATEGORY");
String _data = (String) _m_js.get("SERIES");
RequestContext context = RequestContext.getCurrentInstance();
context.execute("renderChart('container','pie','Exposure by Currency', _data, _cat)");
}
答案 0 :(得分:0)
根据您的代码,_data
和_cat
变量将作为文字而不是其值传递。您只需要正确构建JS执行字符串:
String jsFunctionStr = "renderChart('container','pie','Exposure by Currency','" + _data "','" + _cat + "');";
RequestContext context = RequestContext.getCurrentInstance();
context.execute(jsFunctionStr);