New Instance of the page on Navigation - windows-phone-7

I have a few pages in an Application that require A-Synchronous calls to be made for about 2-3 minutes to get Synchronized, the user may navigate away from that page during Synchronization and can come back again after visiting multiple pages and the sync continues all the time he is on other pages as well, when I go to a page from sync-page and press the Back button everything works fine.. but when i go to a page and navigate back to sync-page from Application Bar a new Instance of the Page is created and the Sync is just like Re-started.
Now i know every thing is working fine since new instance of a page is created when i call NavigationService.Navigate() , but what should i do in this scenario ? How to get the old instance of a page if it is there ?
Thanks...

You can't get an "old" instance of a page and it's not guaranteed that a backwards navigation will reload the previous instance of the page, it may be a new instance of the same page, but restored to the same state (assuming you saved any).
If you are trying to provide backwards navigation from the application bar then a) you probably shouldn't because that's what the back button is for, and b) you should make sure you use NavigationService.GoBack() instead of NavigationService.Navigate() because Navigate will always launch a new instance of your page.
If the page you want to get to is not the previous page, then it sounds like you are trying to implement non-linear navigation for which there is a recipe on the App Hub.
By the sounds of your scenario, you should handle this long running process separately (away from the view) and then display it's progress or results in a view when the user navigates to the relevant page.

Related

Workbox refresh button just one directory

im new here (just start to learn js for this job and my english is not very good) and i'm having some trouble to find the right way to do this.
I'm working on a PWA that will have two main purposes, the first one is to show some html dashboards (one of the htmls dashboard files will be in this path /dashs/dash_geral.html) and the seccond one is to show some lists (e.g: one of them would be in this path /listas/listas_propostas.html), and the goal is to work offline (using cacheFirst strategy).
The problem is that i would want to reload just one folder of my two paths, i can do a "refresh all" in my index.html, but I would want to do it in another pages too, and in one page, i would refresh just one folder, in another page, i would refresh a seccond folder.
My scheme is something like this:
Index.html -> Install sw. Im my index.html body i have 2 big buttons, one to redirect to graphs (/graphs.html), another button to redirect to lists (/listas.html).
If i click in "graphs", i will be redirected to /graphs.html, and there i will have a topbar with a refresh button, one iframe to show different graphs (one of them is /dashs/dash_geral.html, so, when i call graphs.html he will use one of the dash htmls that i generated, i.e /dashs/dash_geral.html) and a navbar to navigate between another dashs (for example, if i click in "negocios" my iframe would load /dashs/dash_negocios.html).
my graphs.html
My goal is to click on refresh button, and update my cache of /dashs/, ie, update my dashes from server to cache.
And do the same if i click in button lists, i would have the same structure, go to /listas.html, having a couple of htmls in /listas/ to navigate with my navbar, and if i click on reload i would want to refresh just that folder (/listas/*) on cache.
I already saw the advanced recipe to create a refresh button for clients, but i want two different refresh buttons with slightly different behaviours (one would "recache" /dash/, and another /listas/.
Besides that, my graphs.html and listas.html are not installing the sw.js, so i shouldn't have access to the main service worker if i'm not in my index.html page, right?
Okay, so, first of all I had misunderstood some stuffs.
I didnt understand before that, firts, if the connection drop, he will continue from the point it stopped (in precache strategy).
Seccond point i didnt understand, is that he will "listen" to all children folders inside scope, i thought that only if I went back to my start_url he will be called again.
I used revision parameter in precache solution to deal with files updates, i actually generate a new SW (with another program) an just change a few lines (the constants used in revision parameters) to update my files.
With those to points working, I can actually work with my app without a reload button, since every time i navigate between pages, he will be listening and recaching updates.

Oracle APEX: Reset session on every application launch?

My use case is actually from the standpoint of an Oracle APEX developer. I'm on version 18.2.
I am working on a single-page application. Every time I run my APEX application from Page Designer, I want the session state of my application to essentially reset. Item values should all start out as NULL, or at their defaults.
I've been playing with a Dynamic Action on Page Load, but that's overkill: if I'm testing multi-step series of operations, simulating an end user, across those actions I want session state retained. But every time I make development changes in Page Designer and then click the "Run" button to launch my application, I want a clean slate.
Is it possible? How do I go about it?
Thanks.
How about a simple workaround?
I understand this is a one-page application. Let's call it Page 1. OK, that's what the final result will be.
But, for testing purposes, create another page (Page 2) and a button on it which will perform redirection to page in this application (the one you're working on - Page 1).
Link Builder contains the Clear session state section which lets you specify which page's session state you want to clear - obviously, that will be Page 1.
Basically, you'd make changes to Page 1, but run Page 2 and push the button to go to Page 1. Its session state will be cleared and let you do any tests you want.

How do I get the Router navigate extra "replaceUrl" to work correctly?

I have a contact addition form that can be navigated to from multiple screens in our application.
Once the form is submitted, I then take the user to a screen to view the contact that was added.
When the user then makes use of the back button it should take them back to the screen that they originated from.
This might be the Android back button or one that calls the RouterExtensions back function.
I have made use of the navigate extra replaceUrl when navigating away from the form to the view page.
I have also tried using the skipLocationChange extra when navigating to the form but this creates more issues.
I have created a simple playground page flow that creates not quite the same issue but does throw an error that I don't know what to do with either:
https://play.nativescript.org/?template=play-ng&id=BfVcGZ&v=2
In our app, by making use of the replaceUrl extra, the back button does take the user to the correct page.
However, there is a brief moment where they see the form again. This isn't an ideal user experience.
In the linked Playground I do get an error:
Cannot reattach ActivatedRouteSnapshot created from a different route.
This seems to tell me that replaceUrl is indeed removing the page from the route table.
However, the page isn't destroyed yet and so the app is trying to show a page that it shouldn't.
replaceUrl is not yet supported by Page Router Outlet, there is an open feature request, you might want to register your vote on the feature and follow up there for further updates.

check if data is already loaded in windows phone app

I am coding for a basic windows phone app. First time when the application is getting launched, data is getting loaded properly in listbox. Now after clicking on any item in list box, I am navigating to another page. But when I press back button to come back to main page. a new set of similar data is getting appended to list box items. how do I check whether data was already loaded or not.
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
In my call back MainPage_Loaded I am binding my data.
You should see how navigation works in Windows Phone. When you go back, the Loaded event gets raised every tmie.
The constructor, however, gets called only when the page is created the first time. When you go back, you actually don't call the constructor again, the page is cached. So, in order to stop the data from loading again, you might want to try loading it in the constructor. That's the simplest way.
The other way includes some form of a bool flag which keeps track of that.

Web page expired message in browser

I am implementing a web application using ASP .Net and C#. One of the pages has a requirement that it always needs to be fetched from the server, rather than from the local browser cache. I have been able to achieve this.
We have a back button in the application, which simply invokes javascript:history.back() method. The problem is that when the back button is clicked to navigate to the page which is always to be reloaded from the server, the browser displays a "Web page expired message".
The intent here is to force the browser to reload the page rather than display the web page expired message.
Any help would be highly appreciated. Thanks a ton in advance.
You will probably need to change the implementation to make the browser load the URL explicitly:
window.location.href = 'http://....';
instead of invoking the back button, since the intention of the back button is to get the last page from the cache.
(If browsers would not act that way, they would re-send your form data multiple times when using the back button during a registration process or similar.)
You mean you want to control browser behaviour, which is not possible. I doubt you can solve it that way. You could set the expiration time to a small value (1 minute perhaps?) so that the page is still valid if one navigates back quickly.

Resources