Skip to main content

Prevent a duplicate page submit

In one of my project, I try to find the solution for fact that the user unintentionally submit the page more than once. Let's suppose that you have two buttons on one page both of them run submit after click on it. This submit run similar DML in DB. If you have poor internet connection to application server you got chance to click on both buttons before page is refreshed.

Apex provides an attribute on page-level "Allow duplicate page submissions page". As the name implies, this attribute determines whether a single page can be submitted more than once. By default, this attribute is set to "Yes - Allow page to be re-posted". User than submit the same page twice. Therefore, in most cases this attribute should be disabled by setting it to "No - Prevent page from being re-posted".
Oracle Apex Duplicate Submission
The disadvange of this solution is that users are redirected to error page every time a re-post occurred and got an error "ERR-3331 This page was already submitted and can not be re-submitted". So I came up with simple solution which you can combine with the APEX solution. 

APEX offer the apex.widget.waitPopup functionality. You can use this to show the wait popup during submitting the page. But let's start from begining.


On page you want this functionality or on page 0 if you want this functionality on all pages in your application, create new Dynamic action.
Dynamic Action

Give the dynamic action a name and choose the event type "Before Page Submit"
Create dynamic action
Create new TRUE action 
Create TRUE part of dynamic action
As action, choose "Execute JavaScript Code", copy and paste the following code in the Code field.

$("body").append('<div class="ui-widget-overlay ui-front"/>');
apex.widget.waitPopup();

Executing Javascript code

This will result in:

Every time when the user clicks on a button which will submit a page, the wait indicator will appear.
Wait indicator
Simple not!

Comments

  1. Thanks, it was very functional

    ReplyDelete
  2. It helps but if there are required fields and the user gets an error, they cannot fix their error and submit the page.

    ReplyDelete

Post a Comment

Popular posts from this blog

Using Oracle Wallets to connect SSL (HTTPS) service in Oracle Database 12c

Recently, I tried to found the complex solution for using Oracle Wallets to connect SSL (HTTPS) service in Oracle Database 12c. I didn't find any and because there are a small changes between Oracle 11g and 12c releases I decided to wrote this blog post. This blog supposes that you have Oracle Database 12c installed and you have admin rights to this database instance. Get Site Certificates In order to make connections to a secured resources, we need to get necessary certificates. The easiest way to do this is using a browser (Chrome and Firefox browsers are preferred). The example below uses the Chrome browser (note: in Chrome version 50 the Connection tab has been dropped when you click the (Green) Padlock for site security info). Using the browser, go to the URL you want to access from PL/SQL. For our example "https://www.redhat.com". Than open the developer toolbar (press F12 or Ctrl+Shift+I) and click on the "Security" tab. Click the "View certi