Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Avoid several launches of the same applet at the same time within the same page

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have jsf/xhtml page in which there are several buttons which all launch the same applet but with different initial values.
The point is to avoid launching several instances of the applet at the same time. That means a user can not have several open applets if he clicks on some of those buttons.
If an applet is currently open, and the user clicks on another button to launch a new applet, he should get an error message that an instance of the applet is open and he can not open a new one. Once the currently open applet is closed, the user can launch a new one by clicking on another button.

For that I used a boolean in init method of the applet. When initializing the applet I set it to true and when submitting or closing the applet, I set this boolean to false within the stop() method which is called while submitting or closing.

The problem: if an applet is open, I click a new button... it do not launch a new applet as this boolean is true. Every things seem good.... but if I click on a button which is previously clicked (used to launch an instance of the applet and that applet is now closed)... it closes the currently loaded applet and load a new one with the initial values of the clicked button. I traced the code, and I saw that when I click a previously clicked button (used to launch an instance of the applet and that applet is now closed) it call first the stop method of the open applet and thus that boolean value becomes false and then it thus initialize a new applet. but when I click on a new button (never previously used to launch the applet), it do not call the stop method and thus a new one can not be initialized as the boolean is currently true.

I have no idea what to do...
Many thanks
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic