Hi folks,

I would like to have a general YES/NO alert, which would be called across application with different questions (Title & Label texts will be passed as parameters).

What I need is an ability to catch a response.

So far I did:

  1. In Formspider: created an alert "questionYesNo" and set YES for button1 and NO for button 2. On close set to action "questionYesNo" which called a db procedure: FS_APP.questionYesNoResponse
  2. In database, package: FS_APP
 PROCEDURE questionYesNo(p_title VARCHAR2, p_label VARCHAR2) IS
  BEGIN
    api_alert.settitle('questionYesNo', p_title);
    api_alert.setlabel('questionYesNo', p_label);
    api_alert.show('questionYesNo');
  END;

  PROCEDURE questionYesNoResponse IS
    l_ret VARCHAR2(10);
  BEGIN
    if api_alert.getresponse('questionYesNo') = api_alert.BUTTON1 then
       l_ret := 'YES';
    else
       l_ret := 'NO';      
    end if;
    api_session.add(in_name_tx => 'QUESTION_YES_NO_RESPONSE', in_value_tx => l_ret);
    api_debug.log(in_message_tx => 'l_ret >> '||l_ret);
  END;

3. Test Alert from application after some button is pressed:
    PROCEDURE test_question IS
    BEGIN
        fs_app.questionYesNo(p_title => 'Confirmation', p_label => 'Tes YES /NO reposnse. Check LOG messages in LOG window!');

    api_debug.log(in_message_tx => 'questionYesNoResponse >>>> '||api_session.getValueTX('QUESTION_YES_NO_RESPONSE'));

    if api_session.getValueTX('QUESTION_YES_NO_RESPONSE') = 'YES' then
       fs_app.alertOK('INFO','Yes button pressed');        
    else
       fs_app.alertOK('INFO','No button pressed');
    end if;    
END;

Problem with above is that it's not working correctly as it returns a previous response and not most recent response.

Any idea how to fix it? And probably how to rewrite it so it won't be using SESSION variable?

Note: I don't want to catch an alert response in "questionYesNoResponse" procedure, but in any other one which follows alert invoke. That's because I want to use this alert GENERIC and don't know what db action will be called once button1 or button2 is pressed.

Thanks, Tomas

asked 25 Sep '12, 07:30

Tomeo's gravatar image

Tomeo
162352
accept rate: 3%


Hi Tomas,

Unlike Oracle Forms alerts, Formspider alerts does not stop the code flow, therefore it's not possible to retrieve the alert's response in the same event where the alert is shown. You can only retrieve alert's response when the alert is closed, using "On Close" event of the corresponding alert.

In our projects, in order to use an alert generically, we set a session variable just before showing our alert, this session variable points the procedure which will be called on "On Close" event of our generic alert. Then in a generic procedure which is called on "On Close" event of our alert, we retrieve the alert response and call the necessary procedure following the session variable value;

PROCEDURE questionYesNo(p_title VARCHAR2, p_label VARCHAR2, p_onCloseProcedure VARCHAR2) IS
BEGIN
  api_session.add(in_name_tx => 'QUESTION_YES_NO_ONCLOSE'
                 ,in_value_tx => p_onCloseProcedure);
  api_alert.settitle('questionYesNo', p_title);
  api_alert.setlabel('questionYesNo', p_label);
  api_alert.show('questionYesNo');
END;

PROCEDURE test_question IS
BEGIN
  fs_app.questionYesNo(p_title => 'Confirmation'
                      ,p_label => 'Tes YES /NO reposnse. Check LOG messages in LOG window!'
                      ,p_onCloseProcedure => 'test_question_onClose');  
END;

PROCEDURE test_question_onClose(p_alertReponse varchar2) IS
BEGIN
  if p_alertReponse = 'YES' then
    fs_app.alertOK('INFO','Yes button pressed');        
  else
    fs_app.alertOK('INFO','No button pressed');
  end if;  
END;

Please note that we split your "test_question" procedure into two separate procedures. The first procedure (test_question) just shows the alert, the second one (test_question_onClose) executes your business logic following the alert's response. The test_question_onClose procedure will be called from the generic procedure (questionYesNoResponse) used in "On Close" event of the alert.

-- procedure used in "On Close" event of the alert
PROCEDURE questionYesNoResponse IS
  l_ret VARCHAR2(10);
  l_onCloseProcedure VARCHAR2(255);
BEGIN
  if api_alert.getresponse('questionYesNo') = api_alert.BUTTON1 then
     l_ret := 'YES';
  else
     l_ret := 'NO';      
  end if;

  l_onCloseProcedure := api_session.getvalueTX('QUESTION_YES_NO_ONCLOSE');
  if l_onCloseProcedure = 'test_question_onClose' then
    test_question_onClose(l_ret);
  elsif l_onCloseProcedure = .... then
    ....
  end if;
END;

Kind Regards, Ibrahim

link

answered 25 Sep '12, 10:33

Ibrahim%20Sandalli's gravatar image

Ibrahim Sand... ♦♦
1.5k5
accept rate: 25%

Hi Ibrahim,

thanks for the reply, initially I wanted to have an option without need to modify a "questionYesNoResponse" procedure in case a new use of the alert.

But nevermind, it§s not a big problem for us.

Thanks, Tomas

link

answered 26 Sep '12, 04:56

Tomeo's gravatar image

Tomeo
162352
accept rate: 3%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×2

Asked: 25 Sep '12, 07:30

Seen: 1,296 times

Last updated: 26 Sep '12, 04:56

Related questions


© Copyright Gerger 2017