Thursday, 17 July 2014

How to display an application logo image based on instance (dev/test/prod) in Oracle APEX 4.2

Dear All, 

Recently we got this requirement: 

Client wants to display a clear message in TEST and DEV instance so that portal displays a clear message and the client is not confused.

Since we already know the instance name which is stored in database. we come up with this approach.

"Show the Portal logo based on Instance" i.e. If it is a DEV instance show the DEV logo image , if it is a test instance - show test instance logo and similarly for PROD.

Here is how we achieved

1      Steps needs to be follow to change Portal logo based on instance
i.                 Upload the necessary images to work space
ii.                Create Application Item
iii.               Create Application Computations
iv.              Set the value for Logo image

Let me explain each of the above steps

Step 1: Upload the necessary images to work space
i.                 Open the instance (dev /test/prod)
ii.                Choose the Application.
iii.               Click on Shared components. In the shared components window, scroll down and find Files Components section. Under Files, you can find images. Click on it. Below is the screen shot for your reference.

iv.                 In the Images window, first click on Create button. It will take you to the Upload image window. Browse the required image and click on Upload button as shown below.
Step 2: Create Application Item
i.                 From the Shared Components window select Application Items which is present under Logic components section
ii.                 Now in the Create Application Item window, provide name for the item .In our case I have provided  ‘AI_NAME’ and accept the defaults for other options and finally  click on ‘Create Application Item’ button as shown below


Step 3: Create Application Computations

i.                 Click on the Application Computations option from the  Logic components section under Shared Components
ii.                 Now in the Create Application Computations window follow the steps mentioned in below screenshot and finally click on Create Computation button. 


Let’s take a closer look at Computation value
select decode(name, 'DEV','DEV_Logo_m3_DEV.JPG','TEST','TEST_Logo_m3_TEST.JPG','PROD_Logo_m3.jpg' ) from v$database

In the above SQL code snippet, If it is a
 1) Dev instance  -> DEV_Logo_m3_DEV.JPG
 2) TEST instance  ->TEST_Logo_m3_TEST.JPG
Else it will show PROD_Logo_m3.jpg image. So you can set the image names accordingly.

Step 4: Set the value for Logo image
i.                 Shared Components -> User Interface components section ->User Interface Attributes

ii. As shown in below screen shot the value for Logo text field is ‘#WORKSPACE_IMAGES#&AI_NAME.’

Please note there is a ‘.’(dot) at the end of the expression

Run the application and you can see logo is changed based on the instance. In our case it shows TEST instance image.


That's it !. Hope it's helps you.



No comments:

Post a Comment