View Full Version : Auto Refresh the display of a recordset
Gary Williams
03-10-2009, 10:17 AM
Hi All,
I have a workflow application (asp + MySQL) that allows the clients' managers to add, edit and close work tasks for their staff. As a result, several managers and a number of staff will all be viewing the same overview screen on their individual monitors, simultanuously. What I need to happen is that when one manager amends a task entry, all the other screens automatically refresh to show all users the updated information.
How can this be achieved?
Regards
Gary
shakir
03-10-2009, 06:41 PM
For this I thing work with ajax is better..check any changes in the DB and once found then write to the file.. has to use some time object.. not have any exp on mysql...
Old Pedant
03-10-2009, 09:00 PM
Shakir is probably at least on right track.
You'd probably want to use a JavaScript timer to "hit" the server every NN seconds (you determine NN) and simply ask if there are any changes. If there are, *THEN* you (again using JS) refresh the main screen.
Yes, you could use AJAX for this, but I think that using a hidden <IFRAME> would be simpler. In fact, the entire operation could take place in the hidden <IFRAME>, timer and all.
Spudhead
03-11-2009, 04:49 PM
You could look at the Ajax.PeriodicalUpdater (http://www.prototypejs.org/api/ajax/periodicalUpdater) object that Prototype.js (http://www.prototypejs.org/) offers. It probably means less code for you to write, and I'd say it would increase the separation between your page structure and functionality.
Gary Williams
03-11-2009, 05:08 PM
Yes, I looked at the javascript method as I'm comfortable with that but it's time I strained the grey cells and get to grips with Ajax. I use the Ajax.PeriodicalUpdater object to run a simple on screen clock, but didn't think to use it for the main screen.
I'll let you know how I get on.
Thanks
Gary
Old Pedant
03-11-2009, 08:52 PM
I still think Ajax is likely overkill for this. After all, won't you have to send virtually all the contents of the screen via Ajax??? If people are looking at a recordset "dump", that's likely 80% or more of the contents of the screen. So what harm in simply refreshing the entire screen when an update is needed? Meaning that all you have to do is detect WHEN the update occurs and then force a reload of the main screen.
Could probably write the whole operation in 15 minutes this way.
Gary Williams
03-13-2009, 09:05 AM
Yes, your'e correct. Most of the overview page is a list of current (and completed) workflow tasks. Refreshing all the user overview pages is fine.
OK, so how is a database table update detected? Is this "Polling"? I'll do a quick google search.
Regards
Gary
Gary Williams
03-13-2009, 09:14 AM
In the main table, as several people can update a workflow record, I store the Last_updated_user_id, Last_updated_date and Last_updated_time. I could run an sql query every 60 seconds to find any changed records. But if I find one, how do I instruct the other users browsers to refresh their screens?
Regards
Gary
Spudhead
03-13-2009, 01:29 PM
A "push" approach (where you instigate a content update from the server, rather than a "pull" approach where you get the client browser to request new data) is very hard to implement. Both the iframe and the ajax solutions (unless I'm misunderstanding something about the iframe approach) work on a periodical "pull" for new data, using javascript as the mechanism for timing these events.
This is where - again, unless I've missed something - the AJAX solution is stronger. With the iframe solution, all that the javascript can say is "go and get a latest copy of the listing page and load it into this iframe". You always need it to return a listing. With AJAX, you don't necessarily have to return a listing because the action of making the request doesn't have to clear the content that's already there. The request can say "go and check for updated content; if there is some, fetch the updated listing and drop it into this page element, if there's not, don't do anything".
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.