3 Replies Latest reply on Jul 23, 2013 2:34 PM by SATim

    Problem setting a hidden item value when button clicked with dynamic action or pl/sql process


      Apex 4.1

      Oracle 11g


      I have a page that consists of a main region and several sub regions.  I have a pl/sql process in After Header SET_DISPLAY(:P400_DISPLAY :='MAIN';)

      Three subregions have a contional display where P400_DISPLAY = STORE.  This works in hiding the sub regions.


      Now I want to change the P400_DISPLAY value to STORE to show the subregions when I hit a button.


      I tried creating a dynamic action for on click of the add button but get the following error:

      The selected button uses a 'Button Template' that does not contain the #BUTTON_ID# substitution string

      I went to the templates and found:


      Substitution Strings




      Substitution strings are used within sub templates to reference component values. This report details substitution string usage for this template.
      Substitution StringReferencedFromDescription
      #LINK#YesTemplateTo be used in an "href" attribute
      #JAVASCRIPT#No To be used in an "onclick" attribute
      #LABEL#YesTemplateButton Label
      #BUTTON_ATTRIBUTES#No Button Attributes
      #BUTTON_ID#No Generated button ID will be either the button's Static ID if defined, or if not will be an internally generated ID in the format 'B' || [Internal Button ID]


      I then tried creating a page process, pl/sql, :P400_DISPLAY :='STORE'; when the appropriate button is pressed.  The button action is submit page. However, it does not change the P400_DISPLAY value and the subregions stay hidden.


      Suggestions please on how to fix the template or change the P400_DISPLAY value?

        • 1. Re: Problem setting a hidden item value when button clicked with dynamic action or pl/sql process

          Give your button a static ID (in button attributes) and change your dynamic action to

          Event: click

          Selection Type: jQuery Selector

          jQuery Selector: #your-static-id

          This way you don't have to change the template.


          To solve your region problem, you could create another dynamic action with event Page Load. You could use it to hide your regions and then use the first dynamic action (on click) to show the regions.

          I think using the on click dynamic action to change the value of P400_DISPLAY won't work since the condition of the hidden regions will only be rendered on page load. So changing the value of P400_DISPLAY will not show your regions until you hit refresh.

          1 person found this helpful
          • 2. Re: Problem setting a hidden item value when button clicked with dynamic action or pl/sql process
            Joe Upshaw

            The root issue is that, although you change the value of your page item, it isn't visible to other areas of the page until it is in the session. So, any other action based on the value of your page item; the visibility of a control, a report based on the item's value, etc. will all be unaffected by changing the value of the page item until it has been changed in the session. Even after this the items are stored in the session, you must thereafter do something to cause the value to be reevaluated. To see the effect of this, observe that your page loads and evaluates the value of your page item, it sees that is "MAIN" and hides the regions. However, it doesn't reevaluate them after this.


            So; your choices to get this value set in the session are to either Submit the page, or use JavaScript to set the value in the session. If you use the latter of these, you'll have to do some further work to cause the visibility tests to be re-run, So, let's stick with with the submit method.


            What you've done above sounds correct for this but, there are a lot of decisions you could have made that might have caused things not to happen in the correct sequence.


            Firstly, let's confirm that what I describe above is your problem. From the development environment, load the page, click the button to change the value and submit. Now, click the link labelled Session. Is it still set to MAIN? If so; this is your issue.


            Let's start with the your After Header computation. Did you set it to *only* run if the current value of your page item is NULL??? If not, that's your problem.


            Load Page -> Item set to 'Main' by Computation -> Click Button -> Item set to STORE -> Submit -> Load Page -> Item set to 'Main' by Computation


            See the problem?


            Assuming this isn't the issue, you created a Branch to the same page, right? What is your process point for the Branch? Is it *After* Validation, Computation etc? Because if not, you aren't changing the value before the submit happens.


            I bet it is the first issue but, take a look at these.





            • 3. Re: Problem setting a hidden item value when button clicked with dynamic action or pl/sql process

              Thanks Martina and Joe.  Both answers were very helpful.  I can use the dynamic action fix for a different issue I am running into but Joe nailed it for this problem.  I was submitting the page in the wrong place and not picking up the change.  Sometimes you can't see the forest because of the trees.  Thanks again for the second set of eyes.