For this particular problem, our ICEfaces application receives asynchronous events from our Server component. The first event instructs the client to assign focus to a specific field (which we implement using the requestFocus() method). The second event returns data that was evaluated asynchronously (we update our model with the value). In both cases, Server Push is used to send the updates to the browser.
What we were finding when the issue was raised was that the javascript created that assigned focus was lost by the subsequent UpdateElements (which contained Javascript used for manageing modal dialogs and autocomplete components). It seems to be an intermittent problem, but we thought this was more due to inconsistent time spent in the server triggering these events into the client. I've tried to return some relevant data without our patch in ICEfaces, but due to the difficulty in recreating the error, I am having trouble supplying something to look at.
Whenever we get any updates sent to the browser, we're seeing Javascript for modal dialogs and autocomplete components. I think this is part of the issue, in that both async events trigger updates that contain javascript calls. In the case where the icefaces app receives the Focus async event first, it has the Focus javascript in the UpdateElements. Then, when the Async Deriv event is received, it has Javascript for modal dialogs and autocomplete components. Commands like
new Ice.Autocompleter('mainForm:field_LayFact2024_08082003_090159-Contact-Type','mainForm:field_LayFact2024_08082003_090159-Contact-Type_div',
{frequency:0.2}
,'iceSelInpTxtRow mandatoryFieldRow','iceSelInpTxtSelRow mandatoryFieldSelRow');
When these two commands are coalesced, the original Javascript is lost and focus is never assigned to the desired field in the browser.
However, looking at this again more closely, I'm not really happy with the patch either. We're getting a lot of duplicated calls in the javascript, in regards to the modal and autocomplete calls (one per coalesced command). I've been having a bit of a play, and find this to be a better fit for our app. I've tried to make a patch file that compares the new UpdateElements.java field with the original, unpatched file. Hopefully, it can be applied. It's adding a new private method that attempts to coalesce the Javascript commands (split by semi colons), instead of a blanket replacement. This is working nicely for us locally, as we're preverving all of the javascript events while not duplicating javascript commands that existed in the previous UpdateElements object.
I hope this is enough to go on.
Patch that changes the UpdateElements so that any JavaScript calls being coalesced will be added to previous javascript calls instead of replacing. Created against 1.8.2 open source code.