Friday, October 15, 2010

Preventing user input on a fusion web page when the server is busy

Recently I noticed a reply from Gary Van Matre (Oracle) in an internal discussion thread on 'blocking user input' on a data capture form using JavaScript when the server is busy serving previous request. btw, this reminded me the Glasspane in Java Swing applications - good old days:)

Solution looks very simple and elegant, you may need to just call event.preventUserInput(); from a JavaScript method.

API doc says:
Calling this method prevents all user input while the event is being processed, including while the event is propagated to the server. The UI is automatically unblocked when processing for this event is complete. Ignores request for events that do not propagate to the server.
<af:resource type="JavaScript">
 function showGlasspane(event){
<af:commandButton actionListener="#{bindings.ExecuteWithParams.execute}"
      text="Search" clientComponent="true"
      id="cb1" partialTriggers="t1">
    <af:clientListener method="showGlasspane" type="action"/>

You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema].

How to run this sample?

1. Run test.jspx
2. Click on Search button.

This action in turn trigger the client side JavaScript method first, and then calls ExecuteWithParams action on server. You may notice the change in the mouse cursor at this stage - mouse cursor to an hourglass. And changes back to normal mode, when processing for this event is complete. Thanks to Gary and AdfBaseEvent.preventUserInput()!


jeevan said...

Thanks a lot !
This is such a useful (and well hidden :) ) feature!

Murali Papana said...

Nice :)

Shyam Satish Kumar k said...

For all the command buttons,we have a propery by name 'Blocking', if we set this property to True, we can achieve the same functionality.

Anonymous said...


In FF7, ESC key is not prevented with this approach. in my case i am showing a popup when there is long running activity but pressing ESC key closes the popup eventhough still server is processing the request this is not happening with IE. plz help me

-- Siva G.