newbe javascript refresh prob

S

Steve

Hi,

I have a private website for 20 people that is similar to a web email client
like hotmail.
There are two frames, one on the left with links for "New", "History",
"Todays" and a frame on the right with a table for viewing the contents of
these messages. The left pane checks back with the server every few seconds
to see if any new messages need to be processed and updates count
accordingly.

When 10 new messages arrive, the left pane updates for everyone (Example
New(10))
Anyone who clicks on this link will see these messages in the right hand
pane. However each meassage can be confirmed as processed by any of the
users. Problem is that right now if one of these users confirms a message (9
remaining) the other users will still see the original 10.

I need some method of forcing a refresh on this right hand pane for the
other users that are looking at the New page.
Would the following work.... If a user clicks on a link in the left pane, is
there a way to store the page referenced in a variable, so that when the
leftpane checks back with the server it can see if anyone has processed any
messages and refresh the pane accordingly? Someone had suggested an applet
iw the only way to ahcieved the desired soln and I am hoping for a more
simplistic answer.

Thank you,
Steve
 
S

Sean Jorden

Hi,

I have a private website for 20 people that is similar to a web email
client like hotmail.
There are two frames, one on the left with links for "New", "History",
"Todays" and a frame on the right with a table for viewing the
contents of these messages. The left pane checks back with the server
every few seconds to see if any new messages need to be processed and
updates count accordingly.

When 10 new messages arrive, the left pane updates for everyone
(Example New(10))
Anyone who clicks on this link will see these messages in the right
hand pane. However each meassage can be confirmed as processed by any
of the users. Problem is that right now if one of these users confirms
a message (9 remaining) the other users will still see the original
10.

I need some method of forcing a refresh on this right hand pane for
the other users that are looking at the New page.
Would the following work.... If a user clicks on a link in the left
pane, is there a way to store the page referenced in a variable, so
that when the leftpane checks back with the server it can see if
anyone has processed any messages and refresh the pane accordingly?
Someone had suggested an applet iw the only way to ahcieved the
desired soln and I am hoping for a more simplistic answer.


refreshing right pane is dangerous because someone might be in the middle
of doing something in the right pane, like selecting a message to be
processed. Also, you will never be able to get the kind of time
resolution you need to make sure users are never trying to process a
message that is already processed.

here are two easy things I think would improve the situation.

1. If a user processes a message that is previously processed, notify
them when they try to process it.

2. In left frame, continue to refresh as per normal, but provide some
obvious visual clue if something has changed since the last refresh and
tell them they need to update the right frame.

so you will need to develop logic to determine last vs. current state -
perhaps the left hand frame is a form you keep re-submitting with its
last known state stored somewhere via javascript timers.


hope I have understood your problem correctly.
 
S

Sean Jorden

sorry, last paragraph should say

so you will need to develop logic to determine last vs. current state -
perhaps the left hand frame is a form you keep re-submitting via javascript
timers with its last known state stored in a form variable.
 
S

Steve

Thanks Sean, you have understood the problem perfectly.
I am too new to Javascript to determine if this is possible. If it is, then
I would like to explain to a programmer I am working with how it could be
accomplished without use of an applet.
"refreshing right pane is dangerous because someone might be in the middle
of doing something in the right pane"

I was a bit worried about this too. I do have some Java Validation in the
back end that will not process messages that have already been confirmed,
but you are correct in declaring that the user would need to be notified of
this.
"In left frame, continue to refresh as per normal, but provide some
obvious visual clue if something has changed since the last refresh and
tell them they need to update the right frame."

There is a visual cue although they may not notice it. The count in the left
pane would go from 10 to 9 (ie New(9)).

So if I address the risks above, do I take it that Javascript could indeed
manage to refresh the right pane for only those users who are looking at the
"New" pane?
Can the left pane hold some sort of flag variable (example flag=frame, where
frame could be new,history etc). then when it checks the server every couple
of seconds if someone has processed a "New" message the right frame can be
refreshed?

Steve
 
S

Sean Jorden

Thanks Sean, you have understood the problem perfectly.
I am too new to Javascript to determine if this is possible. If it is,
then I would like to explain to a programmer I am working with how it
could be accomplished without use of an applet.

be warned it will not be possible to get *exactly* what you want in a
stateless (ie HTTP) environment. You need applets which are always
connected if you want sub-second notification. There are hacks you can
use by having a script driven HTML page load forever, spewing out
javascript directives based on server messages, but this can get dicey...
I think you can settle for Ebay-like currency of information here.

I was a bit worried about this too. I do have some Java Validation in
the back end that will not process messages that have already been
confirmed, but you are correct in declaring that the user would need
to be notified of this.

you could even go a step further by locking a message once a user has
merely opened it, but this creates at least 2 further issues,
1) a disagreeable user may lock many at once - you may have to program
limits
2) a user may open something and then forget about it, so you may have to
place time limits on the lock.

but that would make things extrememly current - another user knows the
state of a message as soon as they open it.

Of course, I don't know if these messages are completely contained in a
list, or you have to click on a link in a summary list to get a complete
form.

There is a visual cue although they may not notice it. The count in
the left pane would go from 10 to 9 (ie New(9)).

So if I address the risks above, do I take it that Javascript could
indeed manage to refresh the right pane for only those users who are
looking at the "New" pane?
Can the left pane hold some sort of flag variable (example flag=frame,
where frame could be new,history etc). then when it checks the server
every couple of seconds if someone has processed a "New" message the
right frame can be refreshed?

if you stored the last state - ie date/time and count (you need date as
well because a message could arrive and have been processed since last
refresh, so count would be the same) then you could know if things
changed in reality and make it bright red or something.

I would store those variables in hidden form fields and then re-submit to
server every x seconds.

again, I personally wouldn't refresh the right pane with javascript but
instead let the users know that the information they are looking at isn't
current and they need to click on the left pane again. You said there
were a few other links in the left side, right? They might not even be in
the 'new messages' page.
 
S

Steve

You said there
were a few other links in the left side, right? They might not even be in
the 'new messages' page.

Correct, so I would need to keep track of which link in the left frame they
had clicked on last, as well as the last state.
Of course, I don't know if these messages are completely contained in a
list, or you have to click on a link in a summary list to get a complete
form.

Messages are not completely contained within the list, just summary as you
specified. Full details can be found by clicking on the order number
assocaited within the message.

As I do not require sub second notification I quite like the idea of a
combination of your suggestions.
1. Lock the message, any other users will be notified that it is locked if
they try to act on it.
2. After processed udpate counts in left pane
3. Check for state change and update the right pane for any users that are
looking at "New" messages.

This may be more or less complicated than the applet. Presumably, even the
applet with its sub second notification would still need validation
procedures to ensure that two people did not simoultaneously try to act on
the same message.

I do not really know much about applets. Is it difficult to implement an
applet if its only purpose is to keep track of the last state?

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,079
Messages
2,570,575
Members
47,207
Latest member
HelenaCani

Latest Threads

Top