1 2 Previous Next 20 Replies Latest reply on Jan 15, 2013 2:04 PM by Howard (... in Training)

    How to clear form on a table after a query?

    Howard (... in Training)
      Using Oracle 11.2 and Apex 4.1.
      1. I'm using a form on a table with buttons: QUERY, INSERT, DELETE and CANCEL.
      2. After INSERT and DELETE, the form is cleared.
      3. But I'd like to clear the form after QUERY. Well, I'd like to clear it when the user wants it cleared!
      4. And, in fact, I have a Clear Cache process for the CANCEL button.
      5. When I click CANCEL, there is a flash as the screen repaints.
      6. And what I believe is happening, is that after the cache is cleared, the RCD_ID page variable has the prior value and the "Fetch Row from table" processing is retrieving the record once more.
      7. So I have the values back that I wanted cleared! Seems like I'm being dogged by the ARF functionality. (ARF, ARF!)

      1. I tried changing the "Go to page nn" to clear cache for the page but that seemed to make no difference.
      2. I tried setting the RCD_ID page variable to '' as I do after DELETE but that didn't work for CANCEL either.

      Thoughts?

      I guess it's just me but the extremely annoying part of APEX is that some obvious simple things -- like clearing the form -- have no obvious simple solution. I should clarify, there are a couple of obvious approaches, but none seem to work. One would think that a CLEAR button would be a standard button or that CANCEL had an option to clear the form and or clear a list of items on the page.

      Howard
        • 1. Re: How to clear form on a table after a query?
          DanielB
          option 1
          create a buton and with dynamic action call a js and set "" for each field

          create a button show it after a query
          create a session state process
          and set

          Clear Cache for all Items on Pages (PageID,PageID,PageID)
          and set the current page
          and condicional when press the created button
          • 2. Re: How to clear form on a table after a query?
            Howard (... in Training)
            THANKS!! I'll try this in the morning. Here's what I expect. When ARF sees I've set the RCD_ID page variable to "", it will throw an error!

            Is this all Option1 or are there 3 different options here?

            Can someone explain what happens after INSERT and DELETE to clear the form? That's what I'd like to have CANCEL do.
            • 3. Re: How to clear form on a table after a query?
              Tom Petrus
              I guess it's just me but the extremely annoying part of APEX is that some obvious simple things -- like clearing the form -- have no obvious simple solution. I should clarify, there are a couple of obvious approaches, but none seem to work. One would think that a CLEAR button would be a standard button or that CANCEL had an option to clear the form and or clear a list of items on the page.
              Buttons are not as unflexible as you make them seem. In fact, they are very flexible as they are just buttons. When you use a button to submit the page, all it will do is submit the page and set the request value to its name. With that request value you can then conditionally trigger processes and branches on the server side.
              Clearing a form is an obvious simple thing. When you create a standard form through the wizard, that will work just fine. When you start making additions or alter things, then you should know what you're doing though, before judging that there is no obvious solution. Probably there is just some obvious mistake or oversight when it doesn't work straight away as you'd want.
              Here's what I expect. When ARF sees I've set the RCD_ID page variable to "", it will throw an error!
              If you cleared the cache of the page, then the session state of RCD_ID will be cleared too. The ARF will not retrieve values, and all fields with source type database column will get cleared too to reflect that the primary key is empty. It will not throw an error unless you provide non-existant values as primary key.
              Is this all Option1 or are there 3 different options here?
              there seem to be only 2 options by Daniel. 1 is using javascript, 2 is using a server side process. I'd not use the javascript one though.

              You should really check out your server-side structure, processes and branches. They basically run from top to bottom, sequentially, so you can easily follow the flow. When does a process run, when is there a branch. What do they do?
              6. And what I believe is happening, is that after the cache is cleared, the RCD_ID page variable has the prior value and the "Fetch Row from table" processing is retrieving the record once more.
              7. So I have the values back that I wanted cleared! Seems like I'm being dogged by the ARF functionality.
              Is this RCD_ID an item on the form page? Are you sure the clear cache process runs?
              Is there a branch after this clear cache that redirects to the current page but sets a value? There is no value being set from URL?
              There is no process setting a value to this item after the clear cache?

              Probably the best advice here is to simply run the page in debug mode, press cancel, and see what happens. Look for lines where the session state of RCD_ID is being changed and see where this happens.
              Can someone explain what happens after INSERT and DELETE to clear the form? That's what I'd like to have CANCEL do.
              INSERTs seem to clear the form only because by default they do not return the primary key generated into the primary key item. That will cause the ARF to wipe out the database column fields.
              When generated by the wizard and DELETE has been set as an option an extra process is generated that runs after the row processing. It is called 'reset page', runs conditionally when DELETE has been pressed, and clears the page cache.
              1 person found this helpful
              • 4. Re: How to clear form on a table after a query?
                Howard (... in Training)
                THANKS, TOM!! I'm sure it's as easy as riding a bike or brain surgery -- once you know how everything works together. Kind regards.

                Additional note: Now for a chuckle. After further searching, I see where someone had this to say when asked about impementing a "Query" button:

                <font size=4>"Try it when you have acquired some more skills in Apex."</font>

                Edited by: Howard (DBA in Training) on Oct 31, 2012 7:45 AM
                • 5. Re: How to clear form on a table after a query? SOLVED problem w/ QUERY!
                  Howard (... in Training)
                  Solved the problem with QUERY, I guess. QUERY "works" now but I may break that functionality while trying to fix CANCEL.

                  [Note: A CANCEL which leads to a different page is easy.  But I'm not finding the key to __staying on the same page__ and clearing the form.]

                  If you want to take a look, http://apex.oracle.com/pls/apex/f?p=21997:2 Dever/Ima9Dever

                  Left to be solved: Clear the form when CANCEL is pressed. I show the data in region 2 for reference.

                  What to do:
                  1) Enter 2 in RCD_ID and press QUERY. Record 2 should be retrieved.
                  2) For fun, clear all three data fields manually. Press CANCEL. They are restored. I want them cleared!

                  For the CANCEL button, 1) I clear the page cache and 2) I set the RCD_ID variable (P2_RCD_ID) to ''. But with no effect. When I view the debug report, I don't see any indication that CANCEL was pressed or that those processes were executed. So, maybe they aren't being executed. I see the record being refetched -- which is what I want to avoid.

                  If you get hung up, run page 1 to clear the session state so that page 2 will execute without error.

                  Thanks, Howard
                  • 6. Re: How to clear form on a table after a query? SOLVED problem w/ QUERY!
                    fac586
                    Howard (DBA in Training) wrote:

                    For the CANCEL button, 1) I clear the page cache and 2) I set the RCD_ID variable (P2_RCD_ID) to ''. But with no effect. When I view the debug report, I don't see any indication that CANCEL was pressed or that those processes were executed. So, maybe they aren't being executed. I see the record being refetched -- which is what I want to avoid.
                    The processes are not executed because the the page is not submitted. The Cancel button is performing a redirect, not a submit:
                    apex.navigation.redirect('f?p=21997:2:13040303230582::NO:::')
                    Change the button action to submit, with the request value as "CANCEL".

                    A default, wizard-generated Cancel button will be created to perform a redirect. The anticipation is that the required behaviour is to navigate to another page in the application without modifying session state or running processes.
                    • 7. Re: How to clear form on a table after a query? SOLVED problem w/ QUERY!
                      Joni Vandenberghe
                      I think that the item value is not set because your cancel button is doing a redirect instead of a submit
                      1 person found this helpful
                      • 8. Re: How to clear form on a table after a query? SOLVED problem w/ QUERY!
                        Howard (... in Training)
                        fac586 and Joni,

                        THANK YOU VERY MUCH. I was cancelling, so I didn't think I wanted to SUBMIT anything. I'll work with this and see what happens!

                        Howard

                        OKAY! I think that solves it! Points (Correct) to fac586. Joni I gave you (Helpful Answer) points.

                        God Bless!

                        Edited by: Howard (DBA in Training) on Oct 31, 2012 9:29 AM
                        • 9. Re: How to clear form on a table after a query?
                          Howard (... in Training)
                          Tom,

                          It will take me a while to digest all you've said here. I appreciate the time/effort that went into your answer. I'm learning APEX by working examples, reading tutorials and some texts, and by "doing". What I have missed -- and what I did for my students in a former (work) life -- is a mental model of how various APEX functionality, say, the APEX "page" process, works. Then maybe I would have known that I needed to do a "submit page". Of course, I was working from an example given to me which did not use "submit page" for what they did. Thanks again.

                          Kind regards,
                          Howard
                          • 10. Re: How to clear form on a table after a query?
                            user8800060
                            Hi Howard,
                            I looked your demo provided in below link.
                            http://apex.oracle.com/pls/apex/f?p=21997:2 Dever/Ima9Dever

                            I'm looking for the same requirement, not with clearing cache .. but clicking on Save button should not clear the form.
                            For me when I click on Create button in the form created from table, it just clears the screen ..

                            Can you tell me the logic you used not to clear screen when you click on SAVe button.

                            Any help is appreciated.

                            Thanks
                            • 11. Re: How to clear form on a table after a query?
                              Howard (... in Training)
                              Hi user8800060,

                              (Was wonder if you had a name like Fred or Sue or Mario or Ramesh or ....)

                              But to your question. For a SAVE to keep the data, in the "Action when button clicked" section choose "SQL UPDATE action" as the Database Action. The "SQL INSERT action" probably clears the fields so one doesNOT accidently enter the data multiple times.

                              Kind regards,
                              Howard
                              • 12. Re: How to clear form on a table after a query?
                                user8800060
                                Hi Howard,
                                Thanks for your response. For Create button ,I changed "Action when button clicked" to "SQL UPDATE action", neighther clicking on Create button,inserted data into table not it showed data on the screen.

                                Any other properties need to changed ?

                                Any help is appreciated.

                                Thank you
                                • 13. Re: How to clear form on a table after a query?
                                  user8800060
                                  Hi Howard,
                                  There is a cache in this, the moment I made primary field avaible in the form to enter ,like in your example Rcd_id. Even create button with action "SQL Insert Action" is showing data on the screen.

                                  But it is not clearing screen with any of the button to enter new data.

                                  Thanks
                                  Saritha
                                  • 14. Re: How to clear form on a table after a query?
                                    user8800060
                                    Hi Howard,

                                    Thanks for your below response. Its been posted to my other thread.

                                    " It seems perhaps the CREATE functionality (using the SQL INSERT database action) is to submit the page and then clear the values -- in that order I suppose. (I'm new, too.) Here's what I think you can do.

                                    Now, I suppose you have a "Before Header" or "After Header" process that has an "Automated Row Fetch" type process that you might call Fetch Row from <table_name> -- or something like that. It seems to me, that if, down in this ARF's Condition section, you make the Condition type unconditional, then the column values of the INSERTED/CREATED row will be refetched from the database when the page renders after the INSERT. If you make the conditional say, EXPRESION1 IS NOT NULL and you put the page item that's the primary key there (:P2_RCD_ID was mine), then the just-inserted row will not be fetched because INSERT will have made it null. [Now you might ask, when / how does it find a value and fetch the record in the other case? Excellent question ... but I digress ....]

                                    So by changing this, I controlled the display behavior after INSERT in the demo application. You might try this. I hope it helps.

                                    WARNING: Try this and be sure to exercise all your functionality -- all the buttons. I've had situations where, the primary key page item became NULL or a value not in the database, and then the page reported an error. But since I couldn't display the page, I couldn't clear the field in error! So I had to clear the cache -- I include a "hidden" application page I use to do this during development/testing -- then I could run the page again.

                                    ********************************
                                    Howard

                                    "

                                    I check your demo , now clicking on Insert/Create button doesn't show values on screen. I'm expecting a different behaviour, I want values to be shown on screen after clicking on insert/create button?

                                    Thanks
                                    Saritha

                                    Edited by: user8800060 on Jan 11, 2013 11:36 AM
                                    1 2 Previous Next