Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Regular Contributor
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: How to run background a process on WebWorks

That's right,

But when I link to other page, I will a issue that is the javascript (setTimeout to submit data local) is not work (it just work only page which write this code javascript)
Developer
Posts: 314
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: How to run background a process on WebWorks

options:
1 - dont use different pages
2 - load different pages inside an iframe, and have the timeout in the main window
3 - check for data coverage in each page you load
4 - dont use different pages

Smiley Happy
Nuno
Regular Contributor
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: How to run background a process on WebWorks

function backgroundThread() {
var okay = false;
var i = 0, limit = 10000, busy = false;

var count = 0;
var processor = setInterval(function () {
count++;
alert("Auto submit server! "+count);
if (!busy) {
busy = true;

if (condition) {
okay = true;
}

if (++i == limit) {
clearInterval(processor);
}

busy = false;
}

}, 10000);
}

backgroundThread();
Regular Contributor
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: How to run background a process on WebWorks

I have this code.

I have just test on Ripple simulator (on Chrome), link to other page and it is work well (only write this code on index.html, I can link to other page, It just work well)

But It doesn't work on PlayBook, it just work only page index.html!!

I don't know reason.
Do you have opinions ^^
Regular Contributor
Posts: 81
Registered: ‎03-09-2012
My Device: PlayBook & Bold 9780
My Carrier: n/a

Re: How to run background a process on WebWorks

If you cannot do what you want, then want what you can do!

 

As I see it you have the following scenario:

* The app gathers data which needs submitting to a server

* In case there is a data connection, no problem. Data is sent immediately.

* In case there is no data connection, data needs to be stored locally until there is a connection.

 

You'd like the last bullet to be performed automatically. You could use timers or hook up a function to a couple of strategic events (all user interactions, open close & switch to background of the app)

 

But from the user point of view it can be done much more simple. The user should know when data connection is made available. So you could make a GUI element somewhere on the index page that shows "Data pending" when there is data waiting with a button "Send now" next to it. Simple and easy, and perfectly acceptable for the user. Not??