1 2 Previous Next 21 Replies Latest reply: May 7, 2014 12:24 AM by Tom Petrus RSS

    Tabular form This form contains unsaved changes message

    HarryF

      I am trying to get rid of that message because I have a collection behind the TF so I don't need this reminder. I found this code:

       

      function resetFormCachedData() {

          var c = $x_FormItems($x('report_p294GridEdit'));//report static id

          for (var e = 0; e < c.length; e++) {

              if (c[e].name != "X01") {

                  gTabFormData[e] = c[e].value

              } else {

                  gTabFormData[e] = "0"

              }

          }

      }

       

      Its not clear what goes in place of gTabFormData.

       

      I tried searching through the DOM for report_p294GridEdit in firebug but it looks like firebug search only looks at open nodes.

        • 1. Re: Tabular form This form contains unsaved changes message
          TexasApexDeveloper

          You could look at this link and see if this solution would suffice..: APEX 4.1 is it possible to remove pagination &amp;#034;unsaved changes&amp;#034; message? - Application Express

           

          Thank you,

           

          Tony Miller
          Ruckersville, VA

          • 2. Re: Tabular form This form contains unsaved changes message
            HarryF

            That does not work. I get

             

            ReferenceError: gTabFormData is not defined

               

             

            gTabFormData[e] = c[e].value

            • 3. Re: Tabular form This form contains unsaved changes message
              TexasApexDeveloper

              Ohh, looking further into the posting.. It depends upon the user submitting the page...  Thus the array is available then...

               

              Thank you,

               

              Tony Miller
              Ruckersville, VA

              • 4. Re: Tabular form This form contains unsaved changes message
                Tom Petrus

                What apex version? Very important as the javascript files changed between 4.1 and 4.2 for example. gTabFormData is used in the widget.tabular.js file and is in the apex.widget.tabular namespace.

                Check the file to get some ideas. Eg function _setModified will loop over the items and compare values. You will also need to make sure that upon pagination you are not met with the message. Probably the easiest way would be to update the value in gTabFormData as the value is changed in the form/backend.

                • 5. Re: Tabular form This form contains unsaved changes message
                  HarryF

                  One thing about my approach. It has a query against a collection behind it. I don't know if tabular forms behave differently when there is a table bound to it versus a query against a collection.

                   

                  4.2. This is what I see at namespace

                   

                  /**

                  * @namespace apex.widget.tabular

                  **/

                  apex.widget.tabular = {};

                   

                  This is the setModified. It references gTabFormData.

                   

                      function _setModified ( pRegionId ) {

                          var lModified           = false,

                              lItems              = $x_FormItems( $x( "report_" + pRegionId )),

                              lItemCount          = lItems.length,

                              lChangedItemCount   = tabular.gChangedItems.length;

                   

                          // Iterate over items and check against original values. Also exclude pagination select list (X01) from check.

                          // Set highlight and modified flag.

                          for ( var i = 0; i < lItemCount; i++ ) {

                              if ( ( tabular.gTabFormData[ i ] !== lItems[ i ].value ) && ( lItems[ i ].name !== "X01" ) ) {

                                  $x_Class( lItems[ i ], "apex-tabular-highlight" );

                                  lModified = true;

                              }

                          }

                   

                          // Iterate over previously changed items (built on add row), and set highlight and modified flag.

                          for ( var j = 0; j < lChangedItemCount; j++ ) {

                              $x_Class( tabular.gChangedItems[ j ], "apex-tabular-highlight" );

                              lModified = true;

                          }

                          return lModified;

                      }

                  • 6. Re: Tabular form This form contains unsaved changes message
                    HarryF

                    Is there a way to see what js files are open? I am assuming the file under $ORACLE_HOME is in use but maybe not.

                     

                    Is there a way to overload the paginate function locally so it is not used?

                    • 7. Re: Tabular form This form contains unsaved changes message
                      Tom Petrus

                      If you have a wizard generated form it'll use apex.widget.tabular. Not so if you have a query built with apex_item. It doesn't care if you use a table or a view.

                      You don't need to check files on the filesystem, that won't help. The files are simply references by url and fetched, they're not getting locked. All the apex namespaced objects are included in the desktop-all javascript file when you run the page in normal mode, but you'll get a better idea of which files are being used when you run in debug mode and check the page source or script tag in browser developer tools.

                      There is also no real way to alter the check for modifications. It's also worth mentioning that once you start modifying this behavior you have to be aware that the behavior may change in next version. The docs state that they are internal functions.

                      I wouldn't override paginate, it'll only cover the pagination page and not other page submissions I believe.

                      It might be worth a try to bind change handlers to the items involved, and set their values to the gTabFormData array as they're being changed. That way it'll not detect any changes.

                      This is what the code you posted does: loop over each item in the form and store the value in in gTabFormData. To reference gTabFormData in 4.2, all you need to do is change it to apex.widget.tabular.gTabFormData.

                      • 8. Re: Tabular form This form contains unsaved changes message
                        HarryF

                        This code worked in 4.2

                         

                        function resetFormCachedData() {

                            var c = $x_FormItems($x('report_MYSTATICID'));  // report static id

                        //alert('len='+c.length);

                            for (var e = 0; e < c.length; e++) {

                                if (c[e].name != "X01") {

                                    apex.widget.tabular.gTabFormData[e] = c[e].value

                                } else {

                                    apex.widget.tabular.gTabFormData[e] = "0"

                                }

                            }

                        }

                         

                        Thanks

                        • 9. Re: Tabular form This form contains unsaved changes message
                          TexasApexDeveloper

                          Tom,

                            Sorry to jump into this conversation late, but you said above : "...If you have a wizard generated form it'll use apex.widget.tabular. Not so if you have a query built with apex_item."  What does APEX use if you have a manually created tabular for to track changes?

                          Running into a tabular form with 2 lov's (cascading lov's to boot) and the message is showing up when we paginate, even after having the above function firing, it does not seem to find the X01 when it goes looking for the name object..

                           

                          (APEX 4.2, Oracle 11g, APEX Listener 2.02, Firefox 17 browser)

                          Thank you,

                           

                          Tony Miller
                          Ruckersville, VA

                          • 10. Re: Tabular form This form contains unsaved changes message
                            HarryF

                            Tony, one thing I ran into is a scoping problem that I don't understand.

                             

                            This gave me the pagination message:

                            apex.server.process("PROCESS",

                                    apex.server.process("PROCESS",

                                      {"x01":Id},

                                      {dataType: "text", success: function(pData){

                                        $('input[name="' + teName  + '"]').each(function(){

                                              update items on the page

                                        });

                                      }});

                                      resetFormCachedData();

                            }});

                             

                            This fixed it:

                            apex.server.process("PROCESS",

                                    apex.server.process("PROCESS",

                                      {"x01":Id},

                                      {dataType: "text", success: function(pData){

                                        $('input[name="' + teName  + '"]').each(function(){

                                              update items on the page

                                        });

                                        resetFormCachedData();

                                      }});

                            }});

                             

                            Given these arrays should be scoped outside of this function I don't understand this. I nested multiple levels and I needed to put this at the deepest nested code.

                             

                            harry

                            • 11. Re: Tabular form This form contains unsaved changes message
                              Tom Petrus

                              Tony,

                               

                              When you have a classic report where you use apex_item in the source, apex has no notion of the region being a tabular form. Hence it will not include the tabular widget javascript files. I don't know why it would in your case, something in your setup may be different? Are you sure the region type is not "SQL Query (updateable report)" - which would indicate the region is a tabular form? Or are you use a save before exit plugin or something similar? When I test this with a simple example on a fresh page then I will not get warning messages - at all, just as expected.

                              x02 is used for the row selector column included in a tab form, more specifically the check-all checkbox. I'm not sure what x01 stores. A new page with a tab form on it will not have x01 stored.

                               

                              Harry,

                               

                              That javascript looks very wrong. Why do you have 2 apex.server.process calls nested in eachother? That explains things going wrong really. Also, note that apex.server.process is an async call. You should reset the cached data in the success function just like the items you are changing. That is why the second call works - "more". The reason why you are getting the message depends on what your setup is. For instance, where do you call this code? Did you bind it somehow to the pagination for example? The time and place where you call this may greatly matter. Don't forget that when paginating apex will still use it's internal functionality and check for changes. If your cache-reset is too late, either through executing too late or being executed too late, then it will of course still pop up the message.

                              • 12. Re: Tabular form This form contains unsaved changes message
                                TexasApexDeveloper

                                Tom,

                                  My apologies, Harryf and I work on the same project, but on different pieces of it.  The above question I have was from the 3rd member of our team that is working on a manually built tabular form.  They initially built the tabular form through the wizard, but after it was created, took the select that was reading from a table and now has it reading from a collection built on the form.  He is having to use the apex_item since 2 out of 3 controls on the form are are cascading lov's.  Since tabular forms don't support cascading lov's exactly like normal forms do, he has coded his own items with an on-demand process to handle the syncing of the lov's (pre APEX 4.x coding).

                                 

                                How can we find where APEX is storing the changed items information on a manually built tabular form, so we can disable that annoying message for our users?

                                 

                                (I personally don't know why Harryf has gone and coded his tabular form using a manual tabular form..  He also is using a cascading lov, but I believe you can mix having wizard built controls and the manual apex_item in your tabular forms, can you not?)

                                 

                                Thank you,

                                 

                                Tony Miller
                                Ruckersville, VA

                                • 13. Re: Tabular form This form contains unsaved changes message
                                  HarryF

                                  This was just psuedo code showing the nesting. There is a lot more code. I was just demonstrating. If that outer server process call was not a server process but maybe a jQuery loop that loops through some objects in the DOM I still ran into the problem.

                                   

                                  This was on an onChange Dynamic Action.

                                  • 14. Re: Tabular form This form contains unsaved changes message
                                    Tom Petrus

                                    Tony,

                                    I see, you're gangin up on me   Sure, you can use apex_item calls in a wizard form - I assumed that this was either manual or wizard, not a mix (I hate the mix )

                                    The code above which refills gTabFormData should work - when you look in the javascript file widget.tabular.js, it is _setModified which is called. It loops over the items in the form and compares them with the values in gTabFormData. If there is a change -> show the message. Shouldn't matter whether the item is generated through apex_item or by apex.

                                    That being said, you can do a manual compare by inspecting the values in apex.tabular.gTabFormData and the values retrieved by running

                                    $x_FormItems( $x( apex.tabular.gTabFormReportID ) );

                                     

                                    It stands to reason that by setting the values in gTabFormData equal to those found in the form, no changes should be detected. If it does, something is going "wrong". Can't tell out of hand what.

                                     

                                    Harry,

                                    Good - But I wouldn't have been surprised otherwise too Well - if there are nested calls the execution order is still important of course. It can matter a great deal where you are executing the code of course. Yet again, I can't tell out of hand since your other code may have an effect on it.

                                     

                                    ps: I found where x01 is residing: it's the pagination select list (didn't use the select list which is why I didn't find it right away).

                                    1 2 Previous Next