4 Replies Latest reply on Dec 13, 2019 12:18 AM by John 'JB' Brock-Oracle

    Page is not reloading while navigating from one page to another

    3893507

      Hi,

       

      I have created an application using JET. I navigate from one page to another and i add some data in that page and when i navigate back to my first page it wasn't reloaded (the data

      which i added was not getting reflected in my page). When i run the application in local it works fine.

      But when run my application in fusion it's not working as expected.

       

      JET Version: 7.0

       

      This is the code which i use to navigate back from one page to another.

       

      oj.Router.rootInstance.go('dashboard');

       

      Thanks

        • 1. Re: Page is not reloading while navigating from one page to another
          John 'JB' Brock-Oracle

          Are you an Oracle employee by chance? 

          This statement makes me think that you might be.

          "But when run my application in fusion it's not working as expected."

           

          If you are, please read and follow this post:  Are you an Oracle Employee?

           

          If you are not, can you tell me how you are loading the data on page load?

          I'm making a few assumptions.

           

          1) When you say you are adding data, I'm assuming you mean you are saving this data back to some kind of REST service?

          2) When you go back to the first page it is not showing this new data?  Meaning that it is probably not pulling from the REST service again to get the new data.

           

          --jb

          • 2. Re: Page is not reloading while navigating from one page to another
            3893507

            Hi John,

             

            I'm not an oracle employee.

             

            I'm loading a table of data from REST service in a page and navigating from this page to another page, I'm adding a data in that page and redirecting to the first page on success. But while redirecting the newly added data is not reflecting in the table because he REST service is not calling while redirecting.

             

            As of now i have put a function and i'm calling that service in that function every time i redirect to that page. I don't know whether the process i'm following is correct or not but it's working.

             

            Please suggest correct method.

             

            Thanks

            • 3. Re: Page is not reloading while navigating from one page to another
              1812359

              I suppose it depends on your specific use case. If you don't mind calling the REST service each time then your way seems like it would be just fine.

               

              I have many pages that retrieve from the REST service when the page is entered. I have others where I really don't want to call the REST endpoint again as I know the data will be unchanged, in that scenario I make use of session storage and have a little function that checks whether the session variable exists, if it does it uses that, if it doesnt it calls the REST endpoint.

              • 4. Re: Page is not reloading while navigating from one page to another
                John 'JB' Brock-Oracle

                A really good way to visually see the app flow is to use a few console.log lines.

                Try this:

                 

                In the constructor of your viewModel add:

                 

                console.log('In the constructor of pageName');

                 

                then add this same thing in the self.connected, self.disconnected, and self.transitionCompleted methods.  Change the string of course. 

                Do that in at least two pages in the app.  Now load the default page and watch the browser console as you navigate between the pages.  You will see very quickly the order that things are getting called.

                 

                If you see that the constructor of the original page is not called at all, when you return to it, check to see if the viewModel is being returned as a singleton or a method.

                 

                If you don't see the constructor processed a second time, it is most likely that you are returning something like "return new ViewModel() "

                You can either added method to the root of your viewModel called slf.initialize() {}  and put your REST call in there, or you can change that return statement to be " return ViewModel "

                 

                Hope that helps,

                 

                --jb