views:

1216

answers:

1

Hi all, I'm facing a problem with Icefaces and it's javascript bridge. I don't know what are the changes which made by this bridge after i made a changes in the server-side.

For example: I have a ice:panelPopup component in my page with the visible attribute = "#{bean.customPopUp}". If i changed the "bean.customPopUp" to be "true" the popup is displayed correctly, but what i need to know : what happened in the client, in other word, i need to know if the popup is displayed i need to do some client processing using javascript

A: 

I've been trying to find a solution for component level callbacks also. There doesn't appear to be a good solution to this problem. I've resorted to initiating a recursive polling function in Javascript that handles my task after it detects an update to my component. My backing bean starts the poller() and it runs every 500ms until the component update has occurred.

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);
    }
}

My backing bean:

updateDataModel(); // Causes 'myInputElement' component to update

FacesContext fc = FacesContext.getCurrentInstance();
JavascriptContext.addJavascriptCall(fc, "poller();");

I don't like this solution very much, but there don't appear to be any great answers at this time.

originalbryan