Solved

web page communication with applet

Posted on 1997-03-08
8
350 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
Industry Leaders: 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!

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

685 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