This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes screen refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "screen refresh" Watch "screen refresh" New topic

screen refresh

S Chander

Joined: Jun 13, 2002
Posts: 8

Please redirect me to the appropriate thread if this has been discussed earlier.
I want to refresh HTML screens with updated information without reloading the screen again. The actual aim to refresh the screens without have constant flickering of the screens.I had been trying to have two frames. In one frame I tried to call a servlet to send the updated information. This servlet gets called every 5 seconds or so to check for periodic updates.
Now I want to display the fresh data in the second frame without repainting it. Is there any way to do it? Can I use a javascript function to populate the fresh data in the second frame?
If someone can send some code snippets explaining this it will be of immense help to me.
thanks in advance
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
I did a demo some time ago with this technic.
if you have main page
<frameset cols="100%,*
<frame src=src1 name=content
<frame src=myservlet
and your content frame has a
<form name=form1
<input name=in1
to update it your servlet should generate the following javascript:
top.document.form1.in1.value="new value"
I use this example, since input text is a simpliest thing that you could have. If you need a static text to be changed, you should wrap it into "span" with sertain id, so if
<span id=sp1
than to change the text:
top.document.getElementById("sp1").innerHTML="new value"
Note, that you will have a problem with doing span staff in NS4
it get more complicated, if need to change select's or add/remove some elements - I mean not just edit existing information.
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
Forgot to mention - it may be better to use <IFRAME in one page, instead of a <FRAMESET with frames.
So you will have only one page with hidden IFRAME that will reload your servlet, wich will generate JavaScript to update page content.
S Chander

Joined: Jun 13, 2002
Posts: 8
Thanks for the help Yuriy. I was able to test out a sample screen with your suggestions.
Charlie Sturman
Ranch Hand

Joined: Apr 04, 2002
Posts: 112
I agree. Here's the link:
subject: screen refresh
It's not a secret anymore!