Friday, December 18, 2009

Blocking User on submit Action in a OAF page

This is one of the most frequently required feature in OAF page, in certain conditions. Basically our requirement is to block user from pressing a button twice, i.e.,if a button is pressed for the first time,till the time request processing is going on for the first request on server either the button should be disabled on page or an hourglass should be shown on the page, so that user should not be able to press it again to start another request, before this request's response has been received from server. This is very essential feature where

1) You are lets say creating a account.
2) Doing a transaction.
3) Generating a report.
4) Doing a transaction which takes significant amount of time which can make user impatient and press the button again.

The standard solution for this provided by OAF is setBlockOnEverySubmit API.Whenever a submit action takes place on a page, subsequent submits can be blocked.
When using a blocking on submit technique, when the submit action takes place, the cursor becomes busy and prevents any other submit action until the current submit event has been handled.
The block on submit behavior is not enabled by default on a page. However, For Partial Page Refresh (PPR) events alone, it is enabled by default.
To implement the block on submit behavior on a specfic page, add the following code to the processRequest() of that page CO:

import oracle.apps.fnd.framework.webui.beans.OABodyBean;

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
OAWebBean body = pageContext.getRootWebBean();
if (body instanceof OABodyBean)

But there are exceptions to this API functionality, what if my page has multiple buttons and I want this nature only on press of one of the button.Situations like this the standard solution is using OAProcessing page(See dev guide for OAProcessing page implementation, its explained well!), which is typically used in long running processed.But what if user is not ready to leave the page at all and asks you to block the navigation somehow? What if you are mobile browser, where OAProcessing page does not work fine. Situations like this can be taken care through javascript.
I must repeat again, use this javascript solution only when your requirement is not fulfilled by standard setBlockOnEverySubmit API provided by framework.Ok here are the steps for the javascript solution, which will block the action by making the button disabled as soon as it is pressed and releasing it as soon as your action is finished :

1) Add a button bean , instead of submit button bean. Lets say its id is "item1" in property inspector. Set destination uri property in property inspector as :

2) In process form request, you can catch the event as :

public void processFormRequest(OAPageContext pageContext,
OAWebBean webBean)
super.processFormRequest(pageContext, webBean);

.// the js button click event
// don't use pageContext.getParameter() API to get parameter values
// in R12 because its doing validation on JS paremeters.
// so,instead of getting parameter value from pagecontext
//getting directly from http request.
// ur button event logic in process form request

//remove this parameter from http request

I hope this helps to people which are facing such situations. Happy coding..!


Manoj said...

Hi Mukul,

I have a similar kind of requirement where i have to show a popup message stating that a submit process is already going on. How can i do this ? Need help ASAP.
Thanks in Advance.


Manoj said...

Hi Mukul, i waiting for your reply.

jain teq said...

I have same problem for me if any body can tell me

SEO Companies in India
SEO Services in India
SEO Experts in India

Pavan said...

Hello Mukul,

Thank You. It worked for me

jayterp20 said...

This solution is amazing. Thank you so much for putting this online and keeping the blog all these years.

Naviya Nair said...

I have read your blog its very attractive and impressive. I like it your blog.

Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai Java Training Institutes

Java Training Institutes in Chennai Java Training in Chennai

Rama Krishna said...


I have the same issue in an OAF page and I used this solution and implemented in test instance.
Now, this is working fine and blocking the submit button from multiple clicks when we tested in IE and Mozilla browsers , but it is not working in Chrome browser.

Kindly suggest here.


Ancy merina said...
This comment has been removed by the author.
Chitra devi said...

I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing.. Believe me I did wrote an post about tutorials for beginners with reference of your blog. 
rpa training in bangalore
best rpa training in bangalore
RPA training in bangalore
rpa course in bangalore
rpa training in chennai
rpa online training

carly stoper said...

This website can live streaming , you can join at my site :
agen judi online terpercaya
Prediksi Bola

Thank you

sai said...

Awesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.
python training in chennai
python course institute in chennai

Jayamari R said...

This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
AWS training in chennai

AWS Training in Bangalore

Sjaak Stein said...

Hi Mukul,
Very interesting article.
It works well for me, thank you so much!
I still do have a tiny question:
Can this also be done for more buttons?
I mean: Can I disable/enable 3 buttons at once?
Thanks in advance,
Sjaak (Netherlands)

Sjaak Stein said...

Hi Mukul,
I just managed to get the 3 buttons disable/enable at once.
But when I want to do this for 4 buttons, it doesn't work this way...?
I decreased the number of characters (with shorter parameter-names), without success.
Please can you advise ?

I solved the 3 buttons like this:

Sjaak (Netherlands)