Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reload : all data is gone

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I write an applet, it works, but when I click "reload" or I come back from another page, all data is gone. I check JVM control panel, I check the "cache", still doesn't work.

How to work out this problem ?

Thanks.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean exactly by "all data is gone?" Without knowing what your applet does or how it does it, I can't tell you exactly what the issue is. It could be as simple as your applet being destroyed, then recreated as you browse to other pages; or it could be that you've coded things so that hiding and revealing the applet makes the "data" disappear (for example, a "painting" applet that just paints on the screen without storing the painted strokes in a data structure.)
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

What I am doing is a drawing applet. All points are stored in a static List, all actions are in init(). User could add his points to the List, applet will draw them on screen.

Right now, the problem is , when reload or come back from other page, the points user defined are gone, that mean the static List is fresh again.

How to avoid this ? Should I place data in Start() ?

Thanks
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
init() gets called once when the applet is first loaded, but start() is called each time the page appears, and stop() when it disappears. Sometimes (it varies) destroy() will be called; init() could then be called again.

So if you're really setting everything up in init(), and not destroying the data in stop(), then you're doing the right thing, and things should be working. Do you want to show the code, or is it too long?
 
Robert Aragon
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I think you are talking about the same problem I had, mine was the reverse. I had 2 input boxes for my applet. A username input box, and a password input box. Once a user inputted both, then I wanted the username AND the password to dissappear from the form page. I didn't want another user on the same machine, say in a city library, to reload and resend the same password and username.

If you WANT form information to STAY in the input boxes, you can have the browser save the form info. In firefox, I go to preferences and save form information.

Or you can find out with method keeps it cached and have that method save the info.

Hope this helps.
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Yes, my codings are big. So I just copy the log information here. In the log below, first cycle is first time to load applet, the second one is for "refresh" page. In my coding, start , stop and destroy function all are empty.

You see, both cycle are going same, init->start->stop->destroy. Based on our thinking, the second cycle should only go from start to stop, will NOT go init and destroy. I don't know why ?

Thanks.

 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, as I said, once destroy() is called, then init() will be called before start() is called again. The sequence of calls is perfectly legal. What you'd like to happen is that destroy() isn't called after the first stop(); I don't think there's anything you can do about that, as it's up to the browser (or plugin) to decide.
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Ernest,

1. I rewrite the whole codings. Now it works. But I still don't know where the bug is in OLD version.

One thing for sure, it is not browser problem, not JVM setting-up problem. Has some logic problem in my codings.

2. This is drawing applet, has lots of complex if-else. I focus on the logic , make it work. And then I structure it with MVC, everything is perfect. but I forget to test the reloading-applet. During this stage, I can't find the bug in these big coding.

What a lesson I learn is , in the early phase, we need to design and test the applet lifecycle.

Ernest, thanks for your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic