Solved

web page communication with applet

Posted on 1997-03-08
8
321 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now