我遇到了 Icefaces 的问题,而且它是 javascript bridge 。 我不知道在服务器端进行更改后,这个桥接器所做的更改是什么。
例如:我的页面中有一个 ice:panelPopup 组件,其中visible attribute =“#{bean.customPopUp} ”。如果我将“ bean.customPopUp ”更改为“ true ”,则弹出窗口会正确显示,但我需要知道的是:客户端发生了什么,换句话说,我需要知道是否显示弹出窗口我需要使用javascript进行一些客户端处理
答案 0 :(得分:0)
我一直在努力寻找组件级回调的解决方案。似乎没有一个很好的解决方案来解决这个问题。我已经在Javascript中启动了一个递归轮询功能,它在检测到我的组件更新后处理我的任务。我的支持bean启动了poller(),它每500ms运行一次,直到发生组件更新。
var pollingCount = 0;
var previousValue;
function poller() {
// Kill poller after 30 seconds
if (pollingCount >= 60) {
pollingCount = 0;
return;
}
var currentValue = document.getElementById('myInputElement').value;
if (previousValue != currentValue) {
previousValue = currentValue;
pollingCount = 0;
myFunction();
}
else {
pollingCount++;
setTimeout('poller()', 500);
}
}
我的支持bean:
updateDataModel(); // Causes 'myInputElement' component to update
FacesContext fc = FacesContext.getCurrentInstance();
JavascriptContext.addJavascriptCall(fc, "poller();");
我不太喜欢这个解决方案,但目前似乎没有任何好的答案。