Home > database >  Show/Hide region when button pressed in another page Oracle APEX
Show/Hide region when button pressed in another page Oracle APEX

Time:04-08

I have a Home Page, it shows the status of the information of the company. But some days, there is some delay of information, due to errors in the PL's or in the server. Today I created a new region in the Home Page that shows a disclaimer/text/warning that there is a delay of 5 hours(I will delete this item at the end of the day or the 5 hours of delay). But I want to know if it's possible, that this message (I created another page with a text area item) written by my coworkers, can appear with a button from the other page and then hide the original region in the Home Page.

I'm using Oracle APEX 5.1

Thanks in advance.

CodePudding user response:

Apex does not support push notifications to push messages from the server, but you can use a workaround.

  • Create a region on the home page that displays the message
  • Create a dynamic action on page load to hide the message region if the message text is null
  • Create an an application process return 'Y' if there is a text message to show and 'N' when there is no message. The processing point of this process should be "Ajax Callback...". There are quite a bit of examples on the web on how to use application processes in ajax callback.
  • On your home page, create a javascript function (in section "Function and Global Variable Declaration") that invokes the application process and shows/hides the message regions based on the result.
  • On your home page, execute a javascript timer function (in section "Execute when Page Loads") to check every xx milliseconds for updates.

Notes:

  • As you can see this is quite a bit of relatively advanced work. You might consider showing the message at page rendering time instead.
  • Don't set the number of milliseconds too low. For every user on this page, a request to the database will be fired every xx milliseconds which can lead to a lot of traffic. For a case like yours, I'd set that to every 2 or even 5 minutes.
  • This is just one implementation, there are other options (using events, dynamic actions, etc) but it all boils down to the same technique: process on client running at interval.

CodePudding user response:

So your ask is: Can I control what is shown/hidden in my Home Page from another page? Sure you can! You can try using APEX's Application Settings.

Then just:

  1. Create an application setting (e.g. SHOW_MESSAGE)
  2. Create buttons and a process attached to it calling the SET_VALUE procedure setting SHOW_MESSAGE to Y or N
-- from the Documentation example
begin
    APEX_APP_SETTING.SET_VALUE(
        p_name  => 'SHOW_MESSAGE',
        p_value => 'Y' );
end;
  1. On your home page, just add a Server-Side Condition to the region checking if the GET_VALUE equals to Y
  • Related