I disabled the “Offline” toast message cause I don’t want the user to know when the server is down, but whenever the server comes back up the page automatically refreshes, is there a way to prevent it?
Is this the “toast” when the app goes offline? Is it supposed to look like this? May be a CSS / theme issue?
Gustavo, this code Luca gave me 2 years ago. I was just about to write another post about it — my main purpose is to handle Android “power saving mode” that suspends background network data. So you power off the screen and your WiseJ app breaks. This code seems to work 75% of the time now. Let me know how it works for you.
<script>
Wisej.onNetworkError = function(type, error, code)
{
if (!Wisej.__showingAlertBox) {
var box = new wisej.web.AlertBox().set({
message: “Trying to reconnect to the server…”,
icon: “warning”,
alignment: “topCenter”,
showProgressBar: true,
showCloseButton: false,
autoCloseDelay: 30000
});
box.addListenerOnce(“disappear”, function () {
Wisej.__showingAlertBox = null;
});
Wisej.__showingAlertBox = box;
Wisej.Platform.hideLoader();
Wisej.Platform.blockRoot(true);
box.show();
}
Wisej.Core.refresh(function () {
Wisej.__showingAlertBox.destroy();
Wisej.Platform.blockRoot(false);
});
}
</script>
Hey, thanks for the quick reply!
You’re right, that’s probably not the best solution to my problem, the real issue is that when the connection comes back the user loses their work, the application restarts instead of just refreshing. When I reload the page I don’t lose the form data but when the connection comes back I do, is there a better option to fix this?
Thanks
Hi Gustavo,
In order to achieve what you want, you’ll have to override a JS method in Wisej.
You can do that by adding the following to Default.html.
<script>
Wisej.onLoad = function() {
Wisej.Core.reload = function () {};
}
</script>
However, it is really advised that you leave the reload function as is. It’s necessary to reload the state. What if the user clicks a button that adds a row (for example) and while the server is processing the client loses connection, then when the connection comes back the user doesn’t see that the row was added.
All in all, disabling the reload when the connection is re-established would certainly break the app’s behavior.
HTH,
Alaa
Please login first to submit.