When we navigate to a page it reloads every time. If I previously created some views dynamically in it either programatically or using ui/builder all of this will be lost. Is there a way to save / cache the state of the page and restore it after the page reloading?
Set a boolean variable when you have loaded a page. Whenever navigating back to that page, check the status of the boolean variable in the pageLoad/onNavigatedTo hooked up functions before the actual code in that page.
I'm afraid of that there is no built-in feature for that.
What you can do is to store/reload manually your screen's data in application-settings at the unloaded and navigatingTo events.
Related
So I have a Shell that has a home page and a settings page.
The settings page makes changes to a singleton service that the home's ViewModel is binded to (MVVM).
I have set up break points on the PropertyChangedEvents of elements on the Home page and they hit as soon as changes are made to the service's properties and their PropertyChanged is executed.
However, upon going back to the home page via the Shell, the page's UI only updates when the page is active and visible. This causes fields to flash when they change. But the breakpoints suggest that they should have updated before.
Is there a way to force refresh the UI before or are there any other alternatives?
For now I have made my view perform a Fade In animation so that changes to the ViewModel don't cause flashing.
Even I have a Xamarin Forms Shell app, and I also had the same issue, So what you can do is, Make the common properties Global as in make those properties in App.xaml.cs and mark them as static.
So when the User changes the property on settings change the App.PropertyName.
Then on the OnApearing method of homepage call a method on the ViewModel say LoadDataValues() and read the App.PropertyName and modify the UI as needed.
What this will do is just before the HomePage appears it will keep the UI of HomePage ready.
Let me know if you have further issues.
So I want to store a session variable when a certain link on the page is clicked, so when the link is clicked it goes through to a controller where I set the session variable successfully. Next I click my back button in the browser and echo the session variable out but it doesn't echo out until I refresh the page again.
The idea is the session variable is supposed to update depending on which link is clicked which does work, however if the variable is set and I click another link to update it, then click back in the browser, it still shows the old session variable until I refresh the page where the new one takes effect.
I hope this makes sense & I've worded my question ok, if not let me know if any clarification is needed.
Thanks,
Sam.
Try setting cache header to do not cache like here: https://stackoverflow.com/a/17550224/2529486
Note that App::before doesn't works, but if it's browser I think you
can fix this by using some javascript.
I am working on a project with Oracle APEX. There is one thing that I am not able to figure out.
When I create a form and add data to it and run my application it keeps the data in itself so when I try to run it again it still has the data from the last user.
How do I change that and stop the form retaining the data?
When you create a branch on the page you can provide the page numbers which cache you want to be cleared with the "clear cache" attribute.
When a page is submitted, make sure it triggers a branche where you set this attribute.
As #Non Plus Ultra said, you can use the Clear Cache attribute of a branch, or you can add a "reset page" Process to run when the page is submitted. Which method you use depends on what navigation paths you wish the page reset to happen.
Option
1)Clear Cache --Go to page --> edit page(top left first option after clicking)-->in edit page at bottom some where you will see Clear.
2) create Branch when page renders set rest page in it.
i would suggest option one
My team is creating an MVC4 application which has an upper menu structure that contains menu items specific for the currently logged-in user, and displays the content for the selected menu item below. The menus are displayed in a partial view "_MainMenu" and the MainMenuController Index action is responsible for getting the menu data from the database and returning the menu partial view. The main layout "_Layout" renders the menu by calling #Html.Action("Index", "MainMenu").
We want to avoid hitting the database to get the menu structure data every time the page is refreshed, and we also ideally want to avoid any visible reload of the menu structure when a different menu item is selected.
I've been looking into AJAX, and I've implemented something where selecting a new menu item will load the content for that item below the menu by replacing a div with ID="mainContent" with the content as a partial view (this div lives on the loaded view "MainContent"). In this way, the menu is never re-loaded and the page never refreshes completely (only the different partial content views are swapped in and out as different menu items are selected).
This solution works, but I'm not sure if it's really best practice, or if there's a better solution involving caching. One of the problems with the AJAX solution is the URL never changes from "http://MySite/MainContent". This means that clicking the Back button on the browser doesn't work as expected, and also hitting F5 to refresh the browser page loses the currently displayed page. The refresh issue can probably be resolved by remembering the selected menu item, but I'm still not convinced this isthe way AJAX was intended to be used.
Can someone please tell me if they think caching would be a better solution for this scenario based on their experience.
If the user's menu items are not likely to change, then you could use a simple static Dictionary (the long is the user id) to cache the data in the backend, and refresh it periodically.
Generally, if you do any caching you have to make sure the cached data gets refreshed when underlying data is updated. Therefore it's only simple and safe if you have only one app accessing your DB. If there are multiple apps, then you'll have to add a mechanism to keep the cache in sync.
In project I'm working on we've stored User-Role-Module entities and relationships in DB, and bound module permissions to roles rather than users. Since role permissions aren't likely to change, they're safe to cache.
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.