Print

Animated timer for page load

Posted in Incorporating Javascript in APEX.

There are times when certain reporting pages in APEX may take a long time to load. While the page is loading, it is not clear to the user why the page load is taking some time. It is sometimes useful to have an animated gif to show that the page is still loading.

To do this we need to create a div (and specify the style) as well as a javascript event that is kicked off when the button to refresh the page is pressed.

First, you will need to find an animated gif that you want to use. Upload this gif into your workspace images.
For this example, our file is called ANIMATED_SPINNER.gif.


In the Page Attribues, add the following:

Footer Text:

<style>

#AjaxLoading{padding:5px;font-size:18px;width:200px;text-align:center;left:50%;top:50%;position:absolute;border:2px solid #666;background-color:#FFF;}

</style>

<div id="AjaxLoading" style="display:none;">..Loading Data..<br />~1min<br><img src="#WORKSPACE_IMAGES#ANIMATED_SPINNER.gif" id="wait" /></div>

 

HTML Header:

<script type="text/javascript"></p> <p class="Moobi_Code">function html_Submit_Progress(pThis){

$x_Show('AjaxLoading');

window.setTimeout('$s("AjaxLoading",$x("AjaxLoading").innerHTML)', 100);

doSubmit('REFRESH');

}

</script>



page_detail



Then you will have to update your button so that it calls the javascript when the button is pressed.

In our "REFRESH" Button, we set the Target to a URL, then enter the URL Target as:

javascript:html_Submit_Progress(this);

button_01button_02


Print

Custom User Table with Roles

Posted in Authentication & Authorisation.

In some cases, I have developed applications that use an Active Directory or some other form of Authentication to log into the application, but we need to manage the Authorisation schemes within the application.

The best way is to create a custom table with the users details, and then one column FOR EACH role that you want to distinguish in your application.

Each of these "role" columns will contain either a 0 or 1.

Table Definition:

CREATE TABLE "MY_USERS" 
(
"ID" NUMBER,
"APP_USER" VARCHAR2(7 BYTE),
"FULLNAME" VARCHAR2(1000 BYTE),
"EMAIL" VARCHAR2(1000 BYTE),
"MOBILE" VARCHAR2(10 BYTE),
"SUPERUSER" NUMBER,
"ROLE1" NUMBER,
"ROLE2" NUMBER,
"ROLE3" NUMBER,
)



Sample Data:

If you have a table similar to above, you should have some data that looks like this:

ID APP_USER FULLNAME EMAIL MOBILE SUPERUSER ROLE1 ROLE2 ROLE3
1 546789 Mandy Smith This email address is being protected from spambots. You need JavaScript enabled to view it. 09283746 1 1 0 0
2 654785 John Black This email address is being protected from spambots. You need JavaScript enabled to view it. 98785321 0 0 1 0

 


Authorisation Schemes:

You can then set up an Authorisation scheme for each role within the app (or Auth schemes with combinations).

For example:

To set up an Authorisation Scheme, go to Shared Components > Authorisation Schemes > Create

Create a new scheme by giving it a name (that corresponds with the role column) and use the Type = Existis SQL Query with the SQL below.

SELECT * FROM MY_USERS WHERE UPPER(APP_USER) = UPPER(:APP_USER) AND SUPERUSER = 1

 

Authorisation_Scheme_Setup

 

This means that you can apply this Authorisation scheme to Tabs, Page Items, Report Columns, etc

Once this Auth Scheme has been applied to an object, this means that only users with a '1' in the corresponding column will be able to see/access the item.

Print

Email attached CSV file of query from APEX

Posted in General Application.

You can easily write a procedure to write the results of a SQL query in a CSV file, and then email this file as an attachment.

Firstly, you will need a function that takes a SQL query and outputs the text results of this query into a BLOB.





GET_REPORT Function - Turns a query into a BLOB of CSV format

The following function was written by Marc Sewtz (more information can be found: http://marcsewtz.blogspot.com/2008/04/generating-csv-files-and-storing-them.html )

 

Download an example in a package:

EMAIL_CSV_DATA_PKG.txt

About Me

I currently specialise in developing bespoke applications using Oracle APEX.I have worked with APEX since it was known as HTMLDB, but have also dabbled with E-Business Suite, Oracle AS Portal, ECM, Webcenter and Website Design.

I enjoy working with new clients and assisting them develop custom applications to enhance and improve internal business processes.

Find Me

mandy nerd2