Solved

web page communication with applet

Posted on 1997-03-08
8
336 Views
Last Modified: 2008-03-10
Refer to web page
http://www.andromeda.com/people/ddyer/loa/tournament-1.html

I would like to modify is such that the cells in the table
would push the "launch" button, if necessary, and pass the
identity of the cell to the applet.  There ought to be a
better way to do this than to have an applet running in
every cell.
0
Comment
Question by:ddyer
  • 2
  • 2
  • 2
  • +2
8 Comments
 

Expert Comment

by:amarshal
ID: 1218992
Make the table one big applet??
0
 
LVL 1

Expert Comment

by:tatti
ID: 1218993
I agree with amarshal, that would seem to be the best way of doing it.
Of course, if you run a single applet in every cell, loading them should be quite fast as they all have the same classes and only their parameters differ. That would be the quick'n'dirty approach, I suppose.

0
 

Author Comment

by:ddyer
ID: 1218994
I considered and rejected both of those solutions before posting
the question.

One big applet is not an attractive solution, because it would
have to draw the table too.

Lots of identical applets is not attractive becauase launching
one new applet per cell wouldn't scale very well.  Guaranteed
to break the browser eventually.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Expert Comment

by:cmg
ID: 1218995
If you aren't able to make the table one big applet, then you are asking an applet to get events happening outside itself, which means changing the browser behaviour - not a Java problem!

But you could take the applet off this page, and put a normal html link in each table box. These would each link to a different page which just contains the applet with the parameters set for that game (so you have "game1.html", "game2.html" etc, where all the gamex.html files just have the applet). Then following the link would take you to a blank page in which the applet would run for that game.

Or, if you don't want all these extra files, how about replacing the launch button with a List item so that the user selects the game they want from that?

I realise neither is really what you want, but I don't think what you want can be done ;)
0
 

Author Comment

by:ddyer
ID: 1218996
"You can't do that" isn't the answer I wanted, so I did my own
research.  The answer is to use a javascript form like:

 <script> document.AppletName.DoSomething("argument"); </script>

to use an applet invoked with
 <Applet name="AppletName" ...></applet>

and to give the applet a public method like
 public void DoSomething(String arg)
 {..}


0
 

Expert Comment

by:cmg
ID: 1218997
I'm sorry, I assumed you were after a Java answer.
The problem with using Javascript is that many people
(myself certainly included) disable Javascript on their
browsers because of the security holes.
0
 

Expert Comment

by:amarshal
ID: 1218998
Returning to the 'One Big Applet' approach, drawing the table is very simple.  Just use GridLayout to space things, placing one button in each cell.

There are many inconsistencies with Javascript between browsers and they are not as likely to work as Java.
0
 
LVL 3

Accepted Solution

by:
garik earned 50 total points
ID: 1218999
ddyer, LiveConnect solution on your web page is elegant enough and is the best one can come up with, but only for Netscape browser - the only one supporting LiveConnect technology for applet-browser communication. For others, you have to add browser-identification script to avoid a bunch of error messages on non-existing object.
Your launchwith() function can be improved a little bit by adding check on existence of Java objects:
if(document.LoaApplet != null && document.LoaApplet.SetGameName != null)
This would prevent errors while the applet is loading.

    Less elegant, but more universal solution without using LiveConnect is to modify your launchwith() function to generate an HTML in a new window and write there applet call with corresponding game name:

win = null;

function launchwith(game) {
if(win == null) {
    win = window.open("", "appletWindow", width=400, height=300, ...);
}
win.document.write
    ("<HTML><HEAD><TITLE>Lines of Action</TITLE></HEAD>");
win.document.write
    ("<BODY><APPLET ...><PARAM NAME='game' VALUE="+game+...
...

Subsequent calls to launchwith() will overwrite the contents of appletWindow with a new game parameter for the applet.

Hope it solves your problem.
Good luck!
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

832 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