Prism in Offline Mode

69 views
Skip to first unread message

Daniel

unread,
Nov 18, 2009, 5:20:52 AM11/18/09
to mozilla-labs-prism
Hi.

Does anyone know how to get Prism to work when the machine is offline?
I use Prism for a webapp running in a local Tomcat. When my machine is
offline (all network devices disabled), Prism tells me to uncheck the
"Work Offline" box in the file menu, which of course is not there.
I tried adding user_pref("toolkit.networkmanager.disable", true); and
user_pref("browser.offline", false); to my webapp's prefs.js, but to
no avail.

Thanks in advance for any help,
Daniel

Harri

unread,
Dec 10, 2009, 8:38:12 AM12/10/09
to mozilla-labs-prism
Hi.

I have the same problem using Prism for a webapp running in a local
Jetty. The application should be able to run offline.
There is different behaviour while starting/running the application
being offline:
- on some machines the application does'n start at all because the
connection to localhost:8080 doesn't work.
- on other machines the application works normaly, as expected.
If I start the application being online and going offline while
working with the application the program doesn't work correctly.

Thanks for help
Harri

Daniel Hohenberger

unread,
Dec 10, 2009, 8:55:00 AM12/10/09
to mozilla-l...@googlegroups.com
Am 10.12.2009 14:38, schrieb Harri:
> - on some machines the application does'n start at all because the
> connection to localhost:8080 doesn't work.
Is your Jetty already (and still) running when you start Prism? We had a
similar problem because our Tomcat shut down too early when Prism took
too long for copying the webapp to th user directory.

For the offline problems, I added the following code to the webapp.js:

// set online on startup
var ioService =
Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
ioService.offline = false;

function myObserver(){
this.register();
}
myObserver.prototype = {
observe: function(subject, topic, data) {
if (topic == "offline-requested") {
if (subject instanceof Components.interfaces.nsISupportsPRBool){
// try to veto going offline
subject.data = false;
}
}
if (topic == "network:offline-status-changed") {
if (data == "offline"){
// go back online
var ioService =
Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
ioService.offline = false;
}
}
},
register: function() {
var obsService =
Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
obsService.addObserver(this, "offline-requested", false);
obsService.addObserver(this, "network:offline-status-changed", false);
},
unregister: function() {
var obsService =
Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
obsService.removeObserver(this, "offline-requested");
obsService.removeObserver(this, "network:offline-status-changed",
false);
}
}

var observer = new myObserver();

Matthew Gertner

unread,
Dec 15, 2009, 11:40:35 AM12/15/09
to mozilla-l...@googlegroups.com
Ah very nice. I used an XPCOM for one client to accomplish the same
thing, but you're right... you can do it straight in webapp.js.

Matt
> --
>
> You received this message because you are subscribed to the Google Groups "mozilla-labs-prism" group.
> To post to this group, send email to mozilla-l...@googlegroups.com.
> To unsubscribe from this group, send email to mozilla-labs-pr...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mozilla-labs-prism?hl=en.
>
>
>

charles

unread,
Dec 29, 2009, 6:10:29 AM12/29/09
to mozilla-labs-prism
Hi

Could you please explain more on how to solve the offline problem?
I can't find webapp.js on my machine.

I'm using Apache to host my web application and my OS is Windows XP.

Thanks in advance,
Charles

Daniel Hohenberger

unread,
Dec 29, 2009, 6:51:00 AM12/29/09
to mozilla-l...@googlegroups.com
On Tue, Dec 29, 2009 at 12:10 PM, charles <charl...@gmail.com> wrote:
> Could you please explain more on how to solve the offline problem?
> I can't find webapp.js on my machine.

The webapp.js is part of the webapp bundle as described here:
https://developer.mozilla.org/en/Prism/Bundles

charles

unread,
Dec 31, 2009, 4:10:46 AM12/31/09
to mozilla-labs-prism
Hi,

I put your scripts under the folder in which webapp.ini resides and it
works!

Thanks!

On 12月29日, 下午7時51分, Daniel Hohenberger <dan...@hd42.de> wrote:

Reply all
Reply to author
Forward
0 new messages