Details
-
Type:
New Feature
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: EE-4.0.0.GA
-
Component/s: Bridge
-
Labels:None
-
Environment:ICEfaces 4
-
Assignee Priority:P1
-
Affects:Documentation (User Guide, Ref. Guide, etc.), Sample App./Tutorial
Description
In order to support the notion of offline vs online modalities in ICEfaces, we need to provide support for new window-level "online" and "offline" events.
These events could be used by the application or potentially components to dynamically enable/disable themselves depending on the online status..
These events could be used by the application or potentially components to dynamically enable/disable themselves depending on the online status..
I would suggest that the following code be integrated into the ICEfaces core js lib:
/* Online Listener */ (function() { function OnlineStatusListener(clientId, cfg) { var id = clientId; var onOnline = cfg.onOnline; var onOffline = cfg.onOffline; function deregisterEvents(){ window.removeEventListener('online', updateOnlineStatus, false); window.removeEventListener('offline', updateOnlineStatus, false); } function registerEvents(){ window.addEventListener('online', updateOnlineStatus, false); window.addEventListener('offline', updateOnlineStatus, false); } registerEvents(); updateOnlineStatus(new Object()); function updateOnlineStatus(event) { var elem = document.getElementById(id); if( !elem ){ deregisterEvents(); return; } if( navigator.onLine ){ if( onOnline ){ onOnline(event, elem); } } else{ if( onOffline ){ onOffline(event, elem); } } } return { registerEvents: registerEvents, deregisterEvents: deregisterEvents } }; ice.mobi.onlineStatusListener = { instances: {}, initClient: function(clientId, cfg) { if (!this.instances[clientId]) { this.instances[clientId] = new OnlineStatusListener(clientId, cfg); } else { this.instances[clientId].deregisterEvents(); this.instances[clientId].registerEvents(); } } } })();The Java interface can also be brought into core:
And any components that wish to use the general online/offline listener, whether, ace, mobi, or core, can use the script util renderer:
Like so: