Prevent refresh on server online

0
0

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?

  • You must to post comments
0
0

Is this the “toast” when the app goes offline?  Is it supposed to look like this? May be a CSS / theme issue?

  • Luca (ITG)
    Well, it looks a lot better with our themes. It’s also in ThemeBuilder.
  • You must to post comments
0
0

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>

  • Luca (ITG)
    Wisej 2.something doesn’t use the onNetworkError anymore when going offline. Now it’s all handled automatically and it shows the Offline toast and reloads automatically when it goes back online.
  • You must to post comments
0
0

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

  • Luca (ITG)
    It loses the session probably because the connection switches the IP address. You can disable the client verification in Default.json “validateClient”: false. Also make sure the session timeout is long enough if the connection is gone for longer periods.
  • GUSTAVO MONTEIRO
    Unfortunately it did not work, I’m using version 2.2.25, could that be the problem?
  • You must to post comments
0
0

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

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.