This discussion is archived
1 2 Previous Next 21 Replies Latest reply: Jun 8, 2011 12:22 AM by 853968 RSS

Signed Applet and page reloading

853968 Newbie
Currently Being Moderated
Hello,

I'm having some troubles with an applet i've developped. It serves listening on the serial port, so i had to sign it and that's what i've done. Right.

Second i put it in a page with the deploy.js from oracle with a jnlp. The applet works, run on the first time... But when i go on another page the applet doesn't standby but destroys itself ! And when i return on it the applet initializes again !

What i want is the applet loads the first time and stay loaded on background until the browser is closed. So i'd want run it a first time, change the page and return on the applet's page without initializing again.

Do you have any ideas ?

Thank you !
  • 1. Re: Signed Applet and page reloading
    853968 Newbie
    Currently Being Moderated
    import java.applet.*;

    public class testapplet extends Applet{

         public void init(){
              System.out.println("initializing");
         
         }
         
         public void start(){
              System.out.println("starting");
         
         }
         
         public void stop(){
              System.out.println("stopping");
         
         }
         
         public void destroy(){
              System.out.println("destroying");
         }
    }

    This code shows me that the applet stops and destroys everytime i change of page. Is that normal ???
  • 2. Re: Signed Applet and page reloading
    sabre150 Expert
    Currently Being Moderated
    Why does it have to be an Applet and not simply a Java program?
  • 3. Re: Signed Applet and page reloading
    793415 Pro
    Currently Being Moderated
    flo360 wrote:
    ..Second i put it in a page with the deploy.js from oracle with a jnlp.
    ..Do you have any ideas ?
    Launch it free floating using JNLP and it will be immune to page changes in the browser (or even closing the browser).
  • 4. Re: Signed Applet and page reloading
    853968 Newbie
    Currently Being Moderated
    What do you mean by free floating and how do you do that ? ? Do you mean jawas deploying ? In the jnlp => <offline allowed/> ?

    Thanks
  • 5. Re: Signed Applet and page reloading
    793415 Pro
    Currently Being Moderated
    flo360 wrote:
    What do you mean by free floating and how do you do that ? ? Do you mean jawas deploying ?
    Yes, deploy it using web start, but in the way it could be launched since JWS was introduced in Java 1.2 - free floating in the applet viewer.
    ..In the jnlp => <offline allowed/> ?
    That has nothing to do with it. It is simply a matter of adding a codebase for the JNLP, then directly linking to it (as opposed to referencing the JNLP from an applet element - for an embedded JNLP applet).
  • 6. Re: Signed Applet and page reloading
    sabre150 Expert
    Currently Being Moderated
    The problem I have with this Andrew is that I don't see any advantage in using an Applet over using an Application. Since both can be launched through WebStart what is the advantage of the Applet?
  • 7. Re: Signed Applet and page reloading
    793415 Pro
    Currently Being Moderated
    sabre150 wrote:
    The problem I have with this Andrew is that I don't see any advantage in using an Applet over using an Application.
    It was simply that 'if there is already a working applet - no code conversion is necessary'.
    ..Since both can be launched through WebStart what is the advantage of the Applet?
    Only 'indulging in laziness', really. Of course, if you start with a frame, you can (easily) customize the look and the exit behavior etc. - it is a nicer effect in the end.
  • 8. Re: Signed Applet and page reloading
    sabre150 Expert
    Currently Being Moderated
    Andrew Thompson wrote:
    sabre150 wrote:
    The problem I have with this Andrew is that I don't see any advantage in using an Applet over using an Application.
    It was simply that 'if there is already a working applet - no code conversion is necessary'.
    ..Since both can be launched through WebStart what is the advantage of the Applet
    Only 'indulging in laziness', really. Of course, if you start with a frame, you can (easily) customize the look and the exit behavior etc. - it is a nicer effect in the end.
    :-)
    :)

    !!!!! My smiley keeps disappearing!
  • 9. Re: Signed Applet and page reloading
    793415 Pro
    Currently Being Moderated
    sabre150 wrote:
    .. !!!!! My smiley keeps disappearing!
    As do winks (sad face).
  • 10. Re: Signed Applet and page reloading
    853968 Newbie
    Currently Being Moderated
    Thank you for your support !

    I'm understanding nearly the whole thing. A last one: i have developped an app which i converted into an applet so i'm going to use the app but i want to be sure on a thing:

    Just deploying the app with java web start permit to let the app working on background and changing of webpage doesn't disturb it, right ? But i would like to interact with it from my webpage in order to get informations read on the serial port from the javascript. Is that possible ? Because i'm installing the jnlp and then what i have to do ? There's no link between the page and the applet... Or i didn't understand something !

    Thanks
  • 11. Re: Signed Applet and page reloading
    793415 Pro
    Currently Being Moderated
    flo360 wrote:
    ..i would like to interact with it from my webpage in order to get informations read on the serial port from the javascript. Is that possible ?
    Well that just blows the entire 'webstart, free floating GUI' idea out of the water. You cannot have your cake (independent of the web page) & eat it too (the JavaScript interaction). (sad face)
  • 12. Re: Signed Applet and page reloading
    853968 Newbie
    Currently Being Moderated
    Erf , so how could i do that... What i don't understand is that everywhere i saw tutos about applets everybody talked about init() launched ONLY on the first time and then start() every time the user comes back on the page. The same for stop() and destroy()...

    No idea ?
  • 13. Re: Signed Applet and page reloading
    baftos Expert
    Currently Being Moderated
    flo360 wrote:
    But i would like to interact with it from my webpage in order to get informations read on the serial port from the javascript.
    Assume for a moment that it is possible to keep your applet alive after navigating away from the page.
    Does the javacript serial port reading code survive as well? Can you check this? Because if not, there is no point for the applet to survive.

    And perhaps the solution is to use a free floating JWS application that uses a different mechanism (not javascript) to access the serial port.

    Another idea would be to use the power of javascript to prevent leaving the page or at least warn of the consequences before allowing it.
    I know this can be done, but I forgot how. I can try to find out.
  • 14. Re: Signed Applet and page reloading
    793415 Pro
    Currently Being Moderated
    flo360 wrote:
    Erf , so how could i do that... What i don't understand is that everywhere i saw tutos about applets everybody talked about init() launched ONLY on the first time and then start() every time the user comes back on the page. ..
    I am pretty sure you have it wrong. <tt>init()/destroy()</tt> are called on page entry/reload & exit, while <tt>start()/stop()</tt> are called if the browser is minimized/restored, or maybe if changing between tabs (I'd have to check that).

    Ultimately though, there had been problems with browsers entirely failing to call the <tt>destroy()</tt> method, or implementing their own decisions about when to call <tt>start()/stop()</tt>. I would not rely on any specific behavior for them.
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points