11 Replies Latest reply on Nov 3, 2011 2:54 PM by 555299

    Buttons under APEX 4.0.2 not generating a html REQUEST

    555299
      ... when posting my initial text it seems to have disappeared.

      Anyway, my question was to do with a button request and why I couldn't see it from the 'Before Header' page process (this also applied to 'Select List with Submit'). If I click a button that does a submit (or choose from a 'Select List with Submit'), I can see the request in the 'OnSubmit' page processes but not the page 'OnLoad Before Header' process. If I enter '&REQUEST.' in the 'REQUEST' field of the unconditional branch then the request is available. I always thought by leaving the REQUEST field of the unconditional branch empty the reqest would flow thru as a default so i can test against it in a 'Before Header' process ?

      Also, another scenario I'm confused with, is when I have a button based on a template that has code as:
      <input type="SUBMIT" value="#LABEL#" />,
      I do not get a request at all ? If I change the 'input type' to BUTTON it works fine.

      Thx
      Nigel

      Edited by: theArrow on Oct 31, 2011 5:52 AM

      Edited by: theArrow on Oct 31, 2011 6:05 AM
        • 1. Re: Buttons under APEX 4.0.2 not generating a html REQUEST
          Arie Geller
          Hello Nigel,

          >> If I click a button that does a submit (or choose from a 'Select List with Submit'), I can see the request in the 'OnSubmit' page processes but not the page 'OnLoad Before Header' process.

          That is correct. The REQUEST value is actually implemented using a packaged variable. As such, it’s only available within the same database session it was set. Each APEX page uses two database sessions – one for the Page Rendering phase (the SHOW procedure) and one for the Page Processing phase (the ACCEPT procedure). Hence, a REQUEST value that have been set during page submit will not be available in the following Page Rendering phase, which uses a new database session.

          As you already discovered, you can use the Request field of the page Branch to specifically pass the REQUEST value to the branch target. In this case, that value is passed as a URL parameter.

          >> … If I change the 'input type' to BUTTON it works fine. …

          Setting the REQUEST is an APEX engine logic and not part of the HTML standard. It means that you should define your APEX Button properly, so the APEX engine will identify it correctly, and generate the appropriate code for it. Where the REQUEST value is concerned, it usually means generating a submit code that includes the REQUEST value as a parameter. You are invited to inspect the HTML code generated by the APEX engine to see how it actually done.

          Regards,
          Arie.

          -------------------------------------------------------
          &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

          &diams; Author of Oracle Application Express 3.2 – The Essentials and More
          • 2. Re: Buttons under APEX 4.0.2 not generating a html REQUEST
            555299
            Thanks Arie, I have just one more clarification.

            I need to have a button of type SUBMIT so it still functions when Javascript is turned off. I can easily do this by having a template to base the button on ie <input type="SUBMIT" value="SUBMIT"/>. This allows the page to be submitted but as stated previously there is no REQUEST for code to examine. Is there any other way to declare a button of type submit and to set a REQUEST ?

            Thx
            Nigel
            • 3. Re: Buttons under APEX 4.0.2 not generating a html REQUEST
              Arie Geller
              Hello Nigel,

              >> I need to have a button of type SUBMIT so it still functions when Javascript is turned off

              Are there other buttons (with other functionalities) on this page?

              The problem is not with setting the REQUEST value, as you’ll see next, but setting it to the correct value. Without JavaScript that might be very tricky.

              >> Is there any other way to declare a button of type submit and to set a REQUEST ?

              The REQUEST feature is implement through a packaged variable called apex_application.g_request.

              You can define an after submit process, with a very low sequence (so it will be the first process to be fired), which set the REQUEST value to whatever you need. For example:
              apex_application.g_request := 'SUBMIT';
              All the following processes can now be conditioned by this REQUEST value.

              Regards,
              Arie.

              -------------------------------------------------------
              &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

              &diams; Author of Oracle Application Express 3.2 – The Essentials and More
              • 4. Re: Buttons under APEX 4.0.2 not generating a html REQUEST
                fac586
                Arie Geller wrote:
                Hello Nigel,

                >> I need to have a button of type SUBMIT so it still functions when Javascript is turned off

                Are there other buttons (with other functionalities) on this page?

                The problem is not with setting the REQUEST value, as you’ll see next, but setting it to the correct value. Without JavaScript that might be very tricky.

                >> Is there any other way to declare a button of type submit and to set a REQUEST ?

                The REQUEST feature is implement through a packaged variable called apex_application.g_request.

                You can define an after submit process, with a very low sequence (so it will be the first process to be fired)
                Note that is specifically On Submit - Before Computations and Validations so that the request value is available to computations, validations, and the conditions thereof.
                which set the REQUEST value to whatever you need. For example:
                apex_application.g_request := 'SUBMIT';
                All the following processes can now be conditioned by this REQUEST value.
                Shouldn't that be
                apex_application.g_request := nvl(:request, 'SUBMIT');
                so that genuine JS-triggered requests are not overwritten?
                • 5. Re: Buttons under APEX 4.0.2 not generating a html REQUEST
                  Arie Geller
                  Hello Paul,

                  >> Note that is specifically On Submit - Before Computations and Validations so that the request value is available to computations, validations, and the conditions thereof.

                  Yes, you are correct. I was too lazy to write the full title of the firing point, but things should be made accurate and clear.

                  >> … so that genuine JS-triggered requests are not overwritten?

                  Generally speaking you are correct, however, the OP raises a situation where JavaScript is turned-off, so no genuine JS-triggered setting REQUEST can be fired. That, of course, raises the question of how to identify the pressed button, if there is more than one on page, and that is the reason for my question to the OP.

                  Thanks and Regards,
                  Arie.

                  -------------------------------------------------------
                  &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

                  &diams; Author of Oracle Application Express 3.2 – The Essentials and More
                  • 6. Re: Buttons under APEX 4.0.2 not generating a html REQUEST
                    555299
                    Thank you both for your contributions, it's helped me a lot.
                    We only have 1 submit button per HTML page. We have other buttons but they fire javascript submits. These JS buttons show when Javascript is available but are hidden when it is not. I like the idea of using
                    "apex_application.g_request := nvl(:request, 'SUBMIT'); but I see no actual way of adding a condition to it so nothing else is affected.
                    • 7. Re: Buttons under APEX 4.0.2 not generating a html REQUEST
                      Arie Geller
                      Hello Nigel,

                      >> I like the idea of using "apex_application.g_request := nvl(:request, 'SUBMIT');
                      >> but I see no actual way of adding a condition to it so nothing else is affected.

                      It seems that the condition is built into the *NVL* function. If JavaScript turned-on, the “normal” behavior of APEX buttons will set the *REQUEST* value and the NVL function will not change it (as it’s not null). If, on the other hand, JavaScript is turned-off, only one button, with SUBMIT functionality, should be available. As this is the only case where the REQUEST value will remain null, the NVL function will set it to SUBMIT, as you need.

                      Regards,
                      Arie.

                      -------------------------------------------------------
                      &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

                      &diams; Author of <a href="http://www.amazon.com/dp/1847194524/?tag=packtpubli-20">Oracle Application Express 3.2 – The Essentials and More</a>
                      • 8. Re: Buttons under APEX 4.0.2 not generating a html REQUEST
                        555299
                        Hi, just tried the code suggested above but I get an error in my application saying: Error ERR-1002 Unable to find item ID for item "REQUEST" in application "13100". If I use a javascript button with apex.submit it passes thru this routine fine.

                        I presume for SUBMIT type buttons it does not create a :REQUEST item.

                        I created a page item of :REQUEST and it seems to work.

                        Is this the right thing to do ?

                        Thx
                        • 9. Re: Buttons under APEX 4.0.2 not generating a html REQUEST
                          Arie Geller
                          Hello Nigel,

                          >> I presume for SUBMIT type buttons it does not create a :REQUEST item.

                          You shouldn’t create any REQUEST item. As I previously explained, this is actually a packaged variable.

                          >> just tried the code suggested above but I get an error in my application saying: Error ERR-1002 Unable to find item ID for item "REQUEST" in application "13100".

                          What is the exact code you used? Did you try to assign a value to :request? For assignment, you should use the (qualified) packaged variable.

                          Regards,
                          Arie.

                          -------------------------------------------------------
                          &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

                          &diams; Author of Oracle Application Express 3.2 – The Essentials and More
                          • 10. Re: Buttons under APEX 4.0.2 not generating a html REQUEST
                            fac586
                            theArrow wrote:
                            Hi, just tried the code suggested above but I get an error in my application saying: Error ERR-1002 Unable to find item ID for item "REQUEST" in application "13100". If I use a javascript button with apex.submit it passes thru this routine fine.

                            I presume for SUBMIT type buttons it does not create a :REQUEST item.

                            I created a page item of :REQUEST and it seems to work.

                            Is this the right thing to do ?
                            No.

                            Try
                            apex_application.g_request := nvl(v('REQUEST'), 'SUBMIT');
                            Seems like it doesn't like the bind form of <tt>:REQUEST</tt> in the process code.
                            • 11. Re: Buttons under APEX 4.0.2 not generating a html REQUEST
                              555299
                              OK, looks like I can reference the bind :REQUEST in the onSubmit process for buttons of type 'button' (ie that call apex.submit) but not a button of type SUBMIT (we have to use use code as per fac586 and Arie suggested above). Once the 'apex_application.g_request' is set I can reference the :REQUEST for all types of buttons in the 'Before Header' process.

                              This is fine but it would be a lot easier if apex set the package variable as standard for buttons of type submit and also the :REQUEST is always available (.. apex V4.x ?)

                              Anyway, thanks for your input on this.