?
Solved

Refresh Content

Posted on 2003-03-31
36
Medium Priority
?
1,190 Views
Last Modified: 2008-03-03
I am trying to find a way to refresh some data on a page in a applet sort of matter...

Basically connect to a XML document, and display its contents, and thenhave the numbers refresh every 30-60 seconds...

so if my XML looks like this

<results>
<driver id="333">
<position>3</position>
<lap>132.232</lap>
<link>http://www.driverinfo.com</link>
</driver>

How would I do this in a applet?

Have the applet update the data on the html page everytime the XML stuff changes... doesnt mater if its everytime the data gets updated on the XML or if its a time thing (60 seconds)

Thanks...
please post any questions and I will answer as needed.

Bill D
0
Comment
Question by:B_Dorsey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 17
  • 14
  • 3
  • +1
36 Comments
 
LVL 10

Expert Comment

by:kollegov
ID: 8243076
Add to resulting HTML  (guess in your XSL)

<META HTTP-EQUIV=Refresh CONTENT="30;>

This will force browser to reload page after 30 sec
0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8243086
this just refreshes the page, I want a applet that reloads the numbers... not refresh the whole page.

Thanks anyways

Bill D
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8243094
When you do not want to reload whole page easiest way will be design FLASH movie
(FLASH 6) can load XML data from server
and do simple animating with movie loop for 30 sec to load and refresh data
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:kollegov
ID: 8243108
Or you can use IFRAME for displaying data
and reload IFRAME only each 30 sec
Thus again you would need XSL with META tag
but load this in IFRAME of page

0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8243109
I cant use flash at this time, this is why Iam asking for a java applet of some sort. I would also assume that flash would be reloading an invisible frame within itself (my guess anyways) ...

design specifics are for Java, I would simply put a small Flash object together if I could use flash on the project

Thanks again
Bill D
0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8243118
IFRAMES dont work in Netscape...

Thanks
Bill D
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8243121
<html>
<body>
<iframe src="1.html">
</iframe>
Other content
</body>
</html>

----1.html------- [generated out of XML with applying XSL ]
<html>
<head>
<META HTTP-EQUIV=Refresh CONTENT="1;">
</head>
 <body>
 </body>
</html>
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8243129
IFRAME  work in NN since Netscape 6  
( NN4 is a headache )

When you need something that works in NN4+ MIE4+
Then FLASH solution is optimal
When you can sacrifise NN4 in favor of simplicity then IFRAME is simplier
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8243154
but for NN4 we can use ILAYER

<html>
<script>
if(document.layers) document.writeln('<ilayer src="1.html"></ilayer>')
else                         document.writeln('<iframe src="1.html"></iframe>');
</script>
<br>
<br>
<br>
<br>
<br>
<br>
Some other content
</html>
0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8243157
Flash is not an option, it is asked in the requirements not to.

Netscape Navigator 4.7 is still a commonly used browser, dont ask me why but it is, there audience is actually made up oof 13.5% of Netscape Navigator 4.7 browsers....

I have made this a Flash project already but it has been rejected... they do not want to use flash. I do not know why, but they dont want to.

I really am looking for an applet to handle this.

Thanks Again
Bill D
0
 
LVL 30

Expert Comment

by:third
ID: 8243239
"there audience is actually made up oof 13.5% of Netscape Navigator 4.7 browsers"

these sites shows there are only 1% uses using ns4.x

http://www.w3schools.com/browsers/browsers_stats.asp
http://www.thecounter.com/img/browserstats.jpg
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8243260
Well, It delivered some headach, but it's now work in

<html>


Work in NN4.7, NN6.0,  MIE4+

<script>
function doRefresh() {
     
     if(document.getElementById) {
         document.getElementById('display').src="1.html?"
              +(new Date()).getTime()
     }
     else if(document.layers)  
         document.layers['display'].load("1.html",300)
}
</script>


<body onLoad="setInterval('doRefresh()',1000);">


================<br>
<br>
Some before

<layer NAME="display" src="1.html" width="300" height="200">
<iframe ID="display" src="1.html" width="300" height="200">
</iframe>
</layer>
<spacer type="block" width="300" height="200">

Some after

</body>
</html>

--------------------------------------------

0
 
LVL 10

Expert Comment

by:kollegov
ID: 8243274
Java Applet ( not javascript, this is quite different things )  
is other possible way... but since Microsoft stealed idea from Sun and "invented" dot net
Microsoft no more willing to support JVM in browsers by default
Newer installations of windows are missing now JavaVirtualMachine and thus java applets not supported by default
even in browsers.
So Java Applet is not  good option now too  :(


 
0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8243278
Maybe for them...

Those stats are for those peoples sites (counters) I have the stats for this site, and 13.5% are NETSCAPE NAVIGATOR 4.7 or lower.....

I dont see how this really affects this question, but  Iwanted a applet, and continue to still want a applet, and help towards solving my problem is greatly appreciated.

Third party stats from someones site about their stats really dont affect this.

Thanks Anyways.
Bill D
0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8243284
to add to the stats guy, if you read the bottom of those pages...

You cannot - as a web developer - rely only on statistics. Statistics can often be misleading.

Global averages may not always be relevant to your web site. Different sites attract different audiences. Some web sites attract professional developers using professional hardware, other sites attract hobbyists using older low spec computers.

Also be aware that  many stats may have an incomplete or faulty browser detection. It is quite common by many web stats report programs, not to detect new browsers like Opera and Netscape 6 or 7 from the web log.
0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8243320
I really appreciate your help kollegov...

But the downfall is this.....

If this is the way I go and someone is looking at the data 3/4 of the way down (and these pages can get EXTREMELY long) and the page refreshes he/she is then sent to the top of the page.

Basically when the page refreshes it sends the user back to the top, and then they are forced to start sorting threw and scrolling to the bottom to find the person they were looking for

The reason I am really stuck on a applet as the numbers would just change, and not make the user scroll again.

Again ,  Ireally appreciate your help, but these were our solutions below and it was turned down, along with our solution of flash.

Thanks]
Bill D
0
 
LVL 30

Expert Comment

by:third
ID: 8243330
i never mentioned i relied on statistics. you are the one relying on it since you told us that 13.5% uses ns4.x and lower. i posted that link to let you know what other stats are showing. sorry if i offended you, it is not my real intention.
0
 

Expert Comment

by:Roricka
ID: 8243982
Well, this IS a javascript area, so I figure somebody ought to suggest using it.

How about using setInterval() ? It will call another function repeatedly, and that other function can refresh your numbers:

<html>
<head>
    <script language="javascript1.2">
    <!-- //
   
    var lapcounter = 0;
    var killme;
   
   
    function adjustIt()
    {
        killme = setInterval("adjust()",30000);
        // repeat every 30 seconds
    }
   
    function adjust()
    {
        lapcounter++;
        document.all.changeme.innerHTML = "Lap " + lapcounter;
    }    
    // -->
    </script>
</head>
<body onLoad="javascript:adjustIt()">
    <p id=changeme></p>
</body>
</html>
   
And you can use clearInterval(killme) to stop the whole thing. Of course, you will also probably have some other functionality that actually sets the lapcounter, but in this code it just autoincrements.

Roricka

0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8244016
OK.. you have got my attention <G>

I like that its not refreshing the page... that is great...

Now how do I connect it to my XML page (I assume it has to be with Java) and display my results, and then refresh the results every 30 seconds, as the XML page will be changinging about every 30 to 60 seconds.

Thanks
Bill D
0
 

Expert Comment

by:Roricka
ID: 8244104
"I specialize in the jelly fungi. I only give the fleshy fungi a whirl."

(Comment to John Cage after the composer and amateur mycologist pointed out a potential fatal error to a teacher in a mushroom identification class. When the teacher asked "if you know so much about mushrooms, why are you taking this class" Cage supposedly replied, "I'm taking this class because there's so much about mushrooms I don't know!")

Anyway, I know javascript pretty well, but the XML and java experts will have to weigh in on things now. I really don't know why you have to use java (I presume you mean java, NOT javascript.)

Sorry. Mebbe I get partial credit??

Roricka
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8250658
B_Dorsey , Before saying "and the page   refreshes he/she is then sent to the top of the page."
Please TRY first my proposal (again almost the same but with "long" page)
Oh, I forgot to mention that now 1.html (which loads in iframe or layer)  do not need
<META refresh> tag
This refresh ONLY contents of   iframe  or layer, not the whole page
and this do not throw up member to the top of page

<html>

<script>
function doRefresh() {
   
    if(document.getElementById) {
        document.getElementById('display').src="1.html?"
             +(new Date()).getTime()
    }
    else if(document.layers)  
        document.layers['display'].load("1.html",300)
}
</script>

<!-- set interval in milliseconds -->
<body onLoad="setInterval('doRefresh()',1000);">  


================<br>
<br>
Some before

<layer NAME="display" src="1.html" width="300" height="200">
<iframe ID="display" src="1.html" width="300" height="200">
</iframe>
</layer>
<spacer type="block" width="300" height="200">

Some after
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
The end of page  
</body>
</html>

==============================================================================

As for Java APPLET solution some more thoughts
1. NN4 (if you take care about it) and most of  old  browserhave default JVM 1.1.x
and do not have XML parsing packages installe by default
All standard XML parsers packages is Java 1.2.x at least and need to be bundled with applet
( this will be ~ 0.5MB of applet size, huge loading time )
Bad :(

2. You can say let's transform XML into HTML on server side and display result in applet...
Again browser JVMs 1.1.x do not have  HTML displaying capabilities, this capabilities requires SWING
which was bundled with JVMs much later in, so you would need to bundle swing (several megabytes)  with
applet :(
Bad:(

3. OK, then lets transform XML data on serverside with XSL
in something like java .properties format which can be easy read from stream since very first
java versions.. Then design (presentation)  need to be hardcoded in Java Applet code
Each time you would need to change it's outlook you would need to change java painting code
and recompile applet

So only 3-rd way is something valueable ..
Now we have your XML sample
<results>
  <driver id="333">
       <position>3</position>
       <lap>132.232</lap>
       <link>http://www.driverinfo.com</link>
  </driver>
</results>

This need to be transformed with XSL in simple list like this

driver.1.id=333
driver.1.position=3
driver.1.lap=132.232
driver.1.link=http://www.driverinfo.com

driver.2.id=333
driver.2.position=3
driver.2.lap=132.232
driver.2.link=http://www.driverinfo.com
  ... e.t.c....

Note: that values need to be enumerated and unique,
then you can write load method in applet like this

[ nontested code may contain typos or errors ]

public Properties doLoad( ) {      
       URL url = new URL(getDocumentBase(),"/some/path/transformed.txt");
       URLConnection connection = url.openConnection();
       InputStream is = connection.getInputStream();
       Properties prop = new Properties();
       prop.load(is);
       return prop;
}

Then in painting or event handling code you may do loop

for(int i=1; prop.getProperty("driver."+i+".id")!=null; i++) {
     String link = prop.getProperty("driver."+i+".link");
    // ....  and so on ... use it the way you need
}

-----------------------
Are you ready to code and compile  java applet yourself ?
I have no idea on required functionality
( presentation and  eventhandling )



 

0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8250934
Actually when  Iment that the page refreshes, I know that the IFRAME is the only thing that refreshes...

The contents of the IFRAME are whats going to be long...

So if I have an ifrma and the size of it is 400 pxls wide, and 400 pxls high, that is fine, I understand the "before" the Iframe content nad "afer" the IFRAME content wont refresh, just the stuff in the Iframe,...'

Thats what I am talking about... the content in the IFRAMe is approximently 200 lines and if I am say looking at line 80 and the iframe refreshes (keep in mind I am looking at the data in the IFRAME, that is 200 lines in length) and the IFRAME refreshes the data I was looking at has now refreshed and has moved my line of site from the 80th line to the 1st line and I am forced to scroll down every 30 seconds to look at the driver I am looking for.

I know its not the content on arounf the IFRAME refreshing its just the stuff in the middle....

The problem is that if it constantly is refreshing then the user is constantly scrolling the content of the iframe to find the line they are looking for.

This is why I wanted a applet of some sort that would just update the numbers, and not update the content of the "IFRAME" data....  I hope this clarifys why I am looking for an applet, and not IFRAMES/ILAYERS


Thanks again

0
 
LVL 10

Expert Comment

by:kollegov
ID: 8258427
I can do the applet, but I need to know what to do...
Please at least please describe what you want applet to do..
How data should be visualised and what other functionality you need other than just showing data
0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8258551
Data is visialized in simple table format....just to show the data.... no bells.. no whistles... just show data.... and scrollable after 15 entries (only 15 show and any more then that would be scrolling)

Basically the table should have a row for each XML entry about 50-100, and then a column for each field in that entry .. about 9

Basically this is a scoring monitor for a race (car race)

What I need is the rows to be shown in order of their placing... and their respective data (car #, lap time, etc)

After it connects to the XML sheet It will need to reconnect 60 seconds later and update the data in their respective fields including if a driver moved a position (this means their name would actually move in the table)

This is a  sample of the data....I owuld have put it in a table format but it wouldnt work anywys here....

The numbers and stuff below represent
Entry 1) Current position
Entry 2) Starting Position
Entry 3) Car #
Entry 4) Driver Name
Entry 5) Current Speed/Behind Leaders in Time
Entry 6) Lap
Entry 7) Laps Led
Entry 8) Points
Entry 9) Running/Engine Problem/Etc

This is how they would show up in the XML so it wouldnt matter how you made a sample XML out of the information below as it would/could be made to show the way needed.

1) 2)  3)  4)             5)     6)   7)    8)    9)
1 (1)  89  John David    104.882 201 135* 185 Running
2 (4)  98  Michel Rance  -0.46   201 0    170 Running
3 (32) 96  Tony Raines   -0.62   201 19   170 Running
4 (6)  66  S Whimmer     -0.77   201 8    165 Running
5 (12) 11  Derek Folton  -1.02   201 0    155 Running


Please feel free to ask me more questions...

Thanks

0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8258640
Here is a sample page as to what I want to do (of coarse not as much data as they have.... I just want a dumbed down version of this page ....I just want to be able to load the data like this without relaoding the page

Of coarse I know their applet is a little much cause they have all kinds of extra's but... http://www.nascar.com/races/pitcommand/demo/pitcommand_frameset_exclude.html
0
 

Expert Comment

by:Roricka
ID: 8259353
B Dorsey

I'd like to talk to you about the software on that link, but for offline. Can you drop me an email at rorytony@hotmail.com if you would.

Roricka
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8266536
Why not :)
This is going out from subject of JavaScript area :)
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8281150
1. Do you want to display data just like a table ?
2. Your data sample have LINK in it does this mean it supposed to be
clickable ?      (do not see any clickable items there)
3. Applet on this page
http://www.nascar.com/races/pitcommand/demo/pitcommand_frameset_exclude.html
is Swing applet thus they use java plugin not default java browser bundled
java machine. This might result in 'not-yet-installed' java plugin on client side and
client will need to download and install ~20-30 MB of java runtime..
Pure AWT applets (nonswing) is a bit more complicated to do fancy design
but will work on any browser without requiring plugin installation..
4. Would be data loaded from same server where from page is loaded
or data need to be loaded from some third party server ?
5. When data is on your server than do you have ability to transform it
with XSL in required format ?

0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8282089
1. Yes

2. Is it possible to leave this option as a hanger? (leave it open so we can make it clickable to a 300x350 window to show individual driver data)

3. its jsut a table of data so i dont know if its going to be that  fancy....

4. better make it from  a 3rd party server, that way if it is local it actually can still be nailed via http request instead of making it on the server and later finding out that we have to change to 3rd party server for the XML

5. Can trnasform it as its uploaded, there is seperate software that runs on the telemetry server... the server (telemetry) uplaods several XML files constantly


Thanks
Bill D
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8296923
Well, I put what I have on
http://www.geocities.com/virtual_max/vmaxtable/   
Does this something lile you need ?

Data is formatted in
http://www.geocities.com/virtual_max/vmaxtable/data.txt   
Single row in text file  per cell  

Sorry I can't post here COMPILED files.  as it's not test ones
let me know where to email it

0
 
LVL 10

Expert Comment

by:kollegov
ID: 8296926
text ones... sorry typo
0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8313255
yes that looks like it :)
0
 
LVL 10

Accepted Solution

by:
kollegov earned 2000 total points
ID: 8317381
Well, here is source code when you can compile and modify (customize colors)   yourself
You also would need class TableLayout which you can download from
http://www.squarebox.co.uk/download/table.html


============================= file vmaxtable.java ===========================
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.util.*;
import java.io.*;

public class vmaxtable extends Applet implements Runnable {
   int ncols = 5;   // number of columns in table
   Panel p,p1;
   ScrollPane sp;
   Thread th;

   public void init()  {
      setLayout(new BorderLayout());  
      sp = new ScrollPane();            
      add("Center",sp);
      p = new Panel();
      p1 = new Panel();
     
      sp.add(p1);
      p1.add(p);
      p.setLayout(new TableLayout(ncols,"F",1,1));
      p.setBackground(Color.red);
      p.setForeground(Color.white);
      sp.setBackground(Color.yellow);      
           
   }

   public void doLoad()  {
     String all="";
     try{URL url=new URL(getCodeBase(),getParameter("URL"));        
         BufferedReader dis = new BufferedReader(new InputStreamReader(url.openStream()));
         String s;
         while ((s=dis.readLine()) != null) {
           if (!s.trim().equals(""))  {
                all+=s.trim()+"\n";
             }
           }
        }
     catch (Exception e) { e.printStackTrace();}
   
     StringTokenizer st = new StringTokenizer(all,"\r\n");
     
     int n = p.getComponents().length;
     int i=0;
     for(i=0;st.hasMoreTokens();i++)  {
         if (i < n )  p.remove(i);
         Label l = new Label(st.nextToken());
         l.setBackground(new Color(0x660000));
         p.add(l,i);        
     }
     while (i < n)  {
        p.remove(i);
        i++;
     }
     
     p.validate();
     sp.invalidate();
     sp.validate();
   }
   
   public void start()  {
      th = new Thread(this);
      th.start();
   }
   public void stop()  {
      th = null;
   }
   
   public void run()  {  
      while (th == Thread.currentThread() )  {
          try  {
             doLoad();
             th.sleep(2000);
             repaint();            
          }          
          catch(Exception e)  {
             e.printStackTrace();
             break;
          }
      }
   }

}
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8317382
When you need to change reconnect time, then put time in millis in this line (now it 2000ms)
th.sleep(2000);
0
 
LVL 14

Author Comment

by:B_Dorsey
ID: 8337700
Im still trying to make this work on my end... little confusing, but Im sure that someday I will figure out where all this is going <LOL>

Anyways appreciate all the time and effort :)

Bill D
0
 
LVL 10

Expert Comment

by:kollegov
ID: 8338109
You need to install JDK to compile it
Download and install J2SE (standard edition) from java sun.com
You also can find java tutorial on same site

Then put both files
vmaxtable.java and TableLayout.java in same directory and run in this directory

> javac vmaxtable.java  

On Success you should get 3 files vmaxtable.class,  TableLayout.class , TableOption.class
Add there HTML file with
<APPLET CODE=vmaxtable.class WIDTH=300 HEIGHT=300>
  <param name="URL" value="data.txt">
</APPLET>

and data.txt file with  1 line per cell (one I used for testing)
1
2
3
4
5

6
7
8
9
10

11
12
13
14
15 - hello world

16
17
18
19
20

21
22
23
24
25

21
22
23
24
25

21
22
23
24
25

21
22
23
24
25


1
2
3
4
5

6
7
8
9
10

11
12
13
14
15 - hello world

16
17
18
19
20

21
22
23
24
25

21
22
23
24
25

21
22
23
24
25

21
22
23
24
25

1
2
3
4
5

6
7
8
9
10

11
12
13
14
15 - hello world

16
17
18
19
20

21
22
23
24
25

21
22
23
24
25

21
22
23
24
25

21
22
23
24
25

And that's all ...  






0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question