10 Replies Latest reply: Jan 21, 2013 10:44 AM by fac586 RSS

    How to initialize all page items at page start time?

    Kim2012
      Hi Apexers,

      It appears that, by default, when you re-enter a page, the page items retain their values from the previous invocation of the page. Is there an easy way to direct a page to initialize all of its item values every time it starts?

      Thanks,
      Kim

      P.S. I'm running Apex 4.1 and Oracle 11g.
        • 1. Re: How to initialize all page items at page start time?
          Marko Goricki
          Hi Kim2012,

          You have to clear cache of the page (you can do this in branch, on button, in URL link, with process...) or set item property "Source Used" to "Always, replacing any...".

          Br,
          Marko Goricki
          --------------------------
          http://apexbyg.blogspot.com/
          • 2. Re: How to initialize all page items at page start time?
            Joni Vandenberghe
            Hi Kim,

            Check your link or branch, there you will find the option "Clear Cache". Just fill in your target page number there and it will set all items to null before doing anything else.
            • 3. Re: How to initialize all page items at page start time?
              Kim2012
              Thanks for the suggestions. The situation isn't resolved, which is probably my fault for not being clear enough. I'm still a bit of a newbie so I'll try to explain it better.

              One page is calling another by using the Action of "Redirect to Page in this Application". I'm specifying the page number to redirect to and, per your suggestion, I'm entering the same page number in the "Clear Cache" item. In the called page, I have a LOV that is showing a value upon entering the page. I'd like for the LOV to show no value each time the page starts because I want to force the user to choose a value every time they use the page. Even after entering the called page number in the Clear Cached item, the LOV value still appears when the called page starts. Is there something else that I need to do?

              Thanks,
              Kim
              • 4. Re: How to initialize all page items at page start time?
                fac586
                Kim2012 wrote:
                Thanks for the suggestions. The situation isn't resolved, which is probably my fault for not being clear enough. I'm still a bit of a newbie so I'll try to explain it better.

                One page is calling another by using the Action of "Redirect to Page in this Application". I'm specifying the page number to redirect to and, per your suggestion, I'm entering the same page number in the "Clear Cache" item. In the called page, I have a LOV that is showing a value upon entering the page. I'd like for the LOV to show no value each time the page starts because I want to force the user to choose a value every time they use the page. Even after entering the called page number in the Clear Cached item, the LOV value still appears when the called page starts. Is there something else that I need to do?
                Does the item have a Source or Default Value defined that sets it to some LOV value?

                Does the LOV actually contain a value that means "no value selected"? Or the LOV item have Display Null Value/Null Display Value/Null Return Value settings that support this?
                • 5. Re: How to initialize all page items at page start time?
                  Joni Vandenberghe
                  Oh ok. In that case edit the LOV item, and set display NULL values to Yes in the LOV section. Add a text incase of a null value such as "- Please select a value -
                  • 6. Re: How to initialize all page items at page start time?
                    Kim2012
                    The Default Value section appears to be completely undefined.

                    The Source section contains the following settings, which I believe is the default state.
                    a. Source Used: Only when current value in session state is null
                    b. Source Type: Static Assignment
                    c. Maintain Session State: Per Session

                    I experimented with the LOV setting named Display Null Value but it had no effect.

                    The field in question is a dynamic LOV and the table that contains the LOV values does not include a value that indicates "No value selected" or "Please select a value". Is adding a value like that the only approach to achieve "nothing" being selected when entering the page? I'd prefer not to have a dummy row in the table.
                    • 7. Re: How to initialize all page items at page start time?
                      Kim2012
                      BTW, the item in question is a dynamic LOV.

                      When you say "add a text", where is that added? In a field in Apex or as a row in the lookup table?

                      I'd prefer to not have a dummy row in the table that indicates "Please select a value". Is that the only way to achieve having the LOV display no value when the page starts? Currently, it is displaying the first value in the LOV as defined by the Order By clause of the SQL statement.
                      • 8. Re: How to initialize all page items at page start time?
                        fac586
                        Kim2012 wrote:
                        BTW, the item in question is a dynamic LOV.

                        When you say "add a text", where is that added? In a field in Apex or as a row in the lookup table?

                        I'd prefer to not have a dummy row in the table that indicates "Please select a value". Is that the only way to achieve having the LOV display no value when the page starts? Currently, it is displaying the first value in the LOV as defined by the Order By clause of the SQL statement.
                        EITHER

                        Set up the LOV item's null display options:

                        Display Null Value: Yes
                        Null Display Value: - None -
                        Null Return Value:

                        OR

                        Add the dummy row to the dynamic LOV query, not the source table:
                        select '- None -' l, null v from dual
                        union all
                        ...
                          /* LOV query */
                        ...
                        order by 1
                        • 9. Re: How to initialize all page items at page start time?
                          Kim2012
                          Great suggestions. I think we're really close now. I tried both of the approaches that you mentioned. They both had the same result. The "- None -" value is now showing up as the first item in the list of values, but the value being displayed in the item upon starting the page is the second value in the list, which was the first value before adding the "- None -" entry. What the heck!?
                          • 10. Re: How to initialize all page items at page start time?
                            fac586
                            Kim2012 wrote:
                            Great suggestions. I think we're really close now. I tried both of the approaches that you mentioned. They both had the same result. The "- None -" value is now showing up as the first item in the list of values, but the value being displayed in the item upon starting the page is the second value in the list, which was the first value before adding the "- None -" entry. What the heck!?
                            Then we are back to considering whether the Clear Cache on the redirect is not set up properly, or something is setting the value on entry to the page. Check the value of the select list item in the session viewer. Perform the page transition in Debug mode, and search the debug trace for actions that are cearing/setting the item's session state value.