JSF(PrimeFaces)由后台向前台传递参数

框架:JSF(PrimeFaces)

前台传递参数到后台:  将数据放到表单中,提交表单,后台Controller即可获得前台页面中参数的值;

后台传递参数到前台:  即后台Controller向前台页面传递参数,可用如下代码实现:

Controller:

import org.primefaces.context.RequestContext;
......
RequestContext context = RequestContext.getCurrentInstance();
context.addCallbackParam("json", object);


JSF页面可添加如下JS脚本:            

var shouDialog = function(xhr, status, args) {
		var json = args.json;
		if(json == "noSelectedDialog"){
			noSelectedDialog.show();
		}else{
			window.open("#{request.contextPath}/..?json="+json,"_self");
		}
	}


你可能感兴趣的:(JSF,PrimeFaces,传递参数)