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)
{
((OABodyBean)body).setBlockOnEverySubmit(true);
}
...
...
}
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 :
javascript:document.getElementById('item1').disabled=true;submitForm('DefaultFormName',0,{'XXX':'Y'});
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.
if(pageContext.getRenderingContext()
.getServletRequest().getParameter("XXX")!=null)
{
// ur button event logic in process form request
......
//remove this parameter from http request
pageContext.removeParameter("XXX");
}
}
I hope this helps to people which are facing such situations. Happy coding..!
13 comments:
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
Hi Mukul, i waiting for your reply.
I have same problem for me if any body can tell me
SEO Companies in India
SEO Services in India
SEO Experts in India
Hello Mukul,
Thank You. It worked for me
This solution is amazing. Thank you so much for putting this online and keeping the blog all these years.
Hi,
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.
Thanks
Ramakrishna
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
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
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)
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:
javascript:document.getElementById('button1').disabled=true;document.getElementById('button2').disabled=true;document.getElementById('button3').disabled=true;submitForm('DefaultFormName',0,{'XXX':'Y'});
tkx
Sjaak (Netherlands)
Hi All,
The above javascript solution not working for me in PageLayout Region. Disabling only the clicked button. but in page button bar other same button is not disabled.
Can anyone face this scenario.
Thanks
Swamy
Awesome article. It is so detailed and well formatted that I enjoyed reading it as well as getting some new information too.
AWS Course in Chennai
Post a Comment