Solved

Japplet reloading from refresh

Posted on 2004-08-28
11
737 Views
Last Modified: 2008-02-01
Is there anyway to prevent an applet from reloading due to a refresh, or to disable the refresh?  Thanks experts.
0
Comment
Question by:kesea
11 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 500 total points
ID: 11923322
I do not think you can do it. Only way you can do (and only in IE) is to get an administrator to get rid of everything on the top bar (apart the URL address). But again the user can refresh if he clicks on F5.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11923328
What exactly are you trying to achieve?
0
 

Author Comment

by:kesea
ID: 11923337
Oh a little more information, I have a frameset with two frames, I have a JApplet in first Frame and a my website in the second one.  If I hit refresh though the JApplet in the first page reloads and I don't what that to happen, how can I prevent the first Frame from Refreshing, or else the JApplet from Reloading?  Thanks experts.

Kes.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11923358
How do you reaload through the applet? You might be able to reload the frame is you sent the request and then you specify as target the second frame. But there is no way you can prevent the applet from refreshing if the user hits F5.
0
 

Author Comment

by:kesea
ID: 11923365
You can just make the one frame in the frameset reload?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:kesea
ID: 11923370
Oh and I am not reloading through the applet, I am trying to prevent the applet from reloading if the user hits F5.  I have the Japplet spawn some Jframes, but if the user hits F5 then my JFrames will disappear.  :(  I want to prevent this.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11923395
> Oh and I am not reloading through the applet, I am trying to prevent
> the applet from reloading if the user hits F5.  I have the Japplet
> spawn some Jframes, but if the user hits F5 then my JFrames will
> disappear.  :(  I want to prevent this.

You cannot prevent it. F5 loads the whole page. I was thinking that you could send a specific request to the second frame but this is different to hitting F5.
0
 
LVL 92

Expert Comment

by:objects
ID: 11923454
You control what happens when your applet is (re)loaded so you should handle it appropriately.

> but if the user hits F5 then my JFrames will disappear.

Why doesn't it reappear again?
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 11925329
Hi kesea,

JVM generally use applet caches to avoid reload of applet code.
When you hit F5, in fact the applet is stopped and restarted again (stop() and start() methods).
I don't know if it's possible, but you can try to manage the page reloading in the applet like:

public class myJApplet extends JApplet
{
    private boolean started=false,initialized=false;

    public void init()
    {
         if (!initialized)
         {
               initialized=true;
               // ...
         }
    }

    public void destroy()
    {
          // destroy nothing
    }

    public void start()
    {
         if (!started)
         {
               started=true;
               // ...
         }
    }

    public void stop()
    {
          // don't stop the applet
    }
}

It should work if the same applet instance is used when you reload the page. The applet may be hidden during reloading. But reloading should be quicker if you avoid destroying the applet resources and reloading them again.

0
 
LVL 4

Expert Comment

by:omry_y
ID: 11925858
you can't do anything to stop the applet from reloading since when you hit F5, the browser really destroy your applet and re-initialize it.
since you mantioned JApplet, I assume you are using Sun's java plugin;
at least for later versions (1.4+) , when you refresh - your applet gets a new class loader, so even static fields in your classes are lost -
so storing state in static variables will not work.
you need to somehow store your state persistently when your applet goes does, and reload it when it starts.
if your applet is sigined, you can store state on the disk, if its not - you can store state on the server using some serverside component, its a bit complicated.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11994219
:)
0

Featured Post

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

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
endX challenge 2 50
create a gui in perl 3 45
Free Alternative to JIRA 4 55
eclipse java  build path 6 21
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 …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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.

758 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

21 Experts available now in Live!

Get 1:1 Help Now