Monday, October 10, 2011

Glasspane Rendering JavaScript's Issue on IE 7.

If you refer to following link:

http://www.oracle.com/technetwork/developer-tools/jdev/1-2011-javascript-302460.pdf

You will find that the JavaScript listed to render glasspane is as follows:

<af:resource type="javascript">
function enforcePreventUserInput(evt){
        var popup = AdfPage.PAGE.findComponentByAbsoluteId('p1');
        if (popup != null){
                AdfPage.PAGE.addBusyStateListener(popup,handleBusyState);
                evt.preventUserInput();
        }
}
//JavaScript callback handler
function handleBusyState(evt){
        var popup = AdfPage.PAGE.findComponentByAbsoluteId('p1');
        if(popup!=null){
                if (evt.isBusy()){
                        popup.show();
                }
                else{
                        popup.hide();
                        //remove busy state listener (important !!!)
                        AdfPage.PAGE.removeBusyStateListener(popup, handleBusyState);
                }
        }
}
</af:resource>

This JavaScript does not work well when called from a column of a table (for example, if you are calling a PL/SQL function/procedure) on IE 7. If you first select a row in a table, and then click the link to call a PL/SQL function/procedure to render glasspane, then it works fine but if you straight away calls the PL/SQL function/procedure the glasspane does not render at all.

However, after working with Oracle Support, figured out that the fix of this problem is pretty simple. We need to modify function handleBusyState() as follows:

function handleBusyState(evt) {
        var popup = AdfPage.PAGE.findComponentByAbsoluteId('p1');
        if (popup != null) {
                if (evt.isBusy()) {
                        popup.show();
                }
                else if (popup.isPopupVisible()) {
                        popup.hide();
                        AdfPage.PAGE.removeBusyStateListener(popup, handleBusyState);
                }
        }
}

The reason for this is explained in the SR as follows:

"
In this usecase on the action event of a command link you have a client listener that registers a busy state listener. The callback for the busy state listener shows the popup when the busy state is true or hides the popup and unregisters the busy state listener. Registered busy state listeners are invoked before and after every PPR regardless of the events sent to the server. In this scenario, when you register the busy state listener from the action handler, there is already a table selection event in flight. The first invocation of this listener reflects a false busy state. This is correct as it marks the completion of the table row selection event. The logic in the busy state callback hides and unregisters the busy state handler before the action event is even sent to the server. This is why the popup is never shown. The key here is that the busy state listener is not specifically targeted at a component. It reflects any component event sent to the server. The first parameter for the "addBusyStateListener" and "removeBusyStateListener" is just the context that the callback should be invoked on. A simple fix to this issue is to just check to see if the popup is visible before hiding and unregistering the listener.
"

Informed Frank about this fix to update the code corner PDF, but other PDFs are not in synch.
So, pasting this in here for future reference.

For details, refer:

Forum Post: https://forums.oracle.com/forums/thread.jspa?threadID=2246139&start=0&tstart=0
Service Request: SR 3-3985745581: Glasspane rendering in ADF
Bug 12834664: SHOW GLASSPANE WITH JAVASCRIPT CODE DOESN'T WORK FOR IE

 

No comments:

Post a Comment