• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Distinguish multiple Applets in one browser session?

 
Michael Veeck
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have coded a base-class for all my applets "AbstractApplet" which the applets code can access via a static method getInstance() to get some useful information like the current frame, codebase etc.

It is static so that I dont have to pass the handler to the applet through all my code. During the init() of an applet, a reference to the applet is stored in a static variable for that purpose.

Problem:
With modern browsers one can open the same applet in mutiple tabs, which seems to not create a new JavaVM for each applet but runs the applets in the same vm.

The disadvantage seems to be that no two of my AbstractApplet can be run simultaniously in the same VM since the code that calls AbstractApp.getInstance() doesnt know which applet he belongs to (remember that he doesnt get passed a reference to it).

The solution (IMO) would be for the getInstance method to find a way to know which applet the calling method belongs to, but I cannot find anything anywhere about his topic. Does anyknow know?

Thanks in advance
MV
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about the super class keeps a static counter, and each time an applet registers itself with it, the value of the counter is passed back to the applet (and incremented internally). Then that value acts as an ID, and is passed to the super class every time one of the applet calls it.
 
Michael Veeck
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But that ID I would have to pass to all objects/code I create in my applet which want to call the AbstractApplet-class.

What I need is to get hold of the current applet-object that object/code belongs to and I do not think that using a static ounter solves that.
 
James Rydell
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you had any luck with this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic