Skip to main content

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){
    event.preventUserInput(); 
  }
 </af:resource>
<af:commandButton actionListener="#{bindings.ExecuteWithParams.execute}"
      text="Search" clientComponent="true"
      id="cb1" partialTriggers="t1">
    <af:clientListener method="showGlasspane" type="action"/>
</af:commandButton>


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()!

Comments

jeevan said…
Thanks a lot !
This is such a useful (and well hidden :) ) feature!
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…
Hi,

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.
Sharath Ram said…
Thanks for the tip Jobinesh.Does this work on other UI controls as well? I have a af:selectManyChoice and on making a selection , I load another af:selectManyChoice(dependent). Sometimes , the resultset in the dependent is a huge list and takes time to load. On making a selection in the main af:selectManyChoice , I need to prevent the user from selecting any entries in the dependent af:selectManyChoice .It does not seem to work. Any inputs are appreciated. Thanks.

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…