您的位置:首页 > Web前端 > JavaScript

JSF后台代码与前端JS代码交互

2015-02-27 14:14 197 查看
1:父类action中代码

public class BaseAction<T> implements Serializable {

/**

* 请求完成后页面执行可以执行的脚本

*/

protected void executeScript(String script) {

RequestContext rcontext = RequestContext.getCurrentInstance();

rcontext.execute(script);

}

}

2:子类action中代码:

@SuppressWarnings("serial")

@ManagedBean

public class MembermsgReqAction extends BaseAction<Membermsg> implements

Serializable {

public void showLearningProcess(Integer userID){

String time =Long.toString(new Date().getTime());

String key =MD5.Md5(userID.toString()+ new Date().getTime(),32);

//注意,如果参数是字符串,需要双引号+ 单引号

this.executeScript("learningProcess('" + userID + "','" + time + "','" + key + "')");

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: