?
Solved

Saving dirty data from Applet

Posted on 2011-09-25
2
Medium Priority
?
499 Views
Last Modified: 2012-05-12
Hello,

I am trying to save dirty data. After confirming with the user that he wants to save his changes, I wrote code to force a ToolbarController.SAVE event.

I create this event in a SwingUtilities.invokeAndWait code block.
The reason being that I want to allow sufficient time for the dirty data to be saved (from a SaveAction Thread) before destroying my active applet.
I wrote this code in the shutdown() lifecycle method.

The problem is during testing the dirty data is lost.
Any suggestions what could be the problem ?

Here is the code snippet;


SwingUtilities.invokeAndWait(new Runnable() {
   public void run() {
         toolbarController = new    
             ToolbarController(ToolbarModelFactory.getSystemwideToolbarModel());
             ApplicationEvent evt =
                             new ApplicationEvent(ToolbarController.SAVE, toolbarController);
          toolbarController.handleApplicationEvent(evt);
   }
});

Paolo
0
Comment
Question by:ptreves
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Accepted Solution

by:
ptreves earned 0 total points
ID: 36599203
I rewrote my code as follows:

                 System.out.println("SwingUtilities.invokeLater - before CommitAction.start");
                new CommitAction().start();
                     System.out.println("SwingUtilities.invokeLater - after CommitAction.start");

And get the following stackTrace:
Catch ApplicationEvent !!! Force Save of Mutable Table fields.
SwingUtilities.invokeLater - Before
SwingUtilities.invokeLater - before CommitAction.start
SwingUtilities.invokeLater - after CommitAction.start
SwingUtilities.invokeLater - After
basic: Finished applet teardown
network: Connecting http://3.94.247.54/cgi-bin/commitChanges.cgi?sessID=45fc09c587d68bcd4d614d871d568017&output=resultCodes with proxy=DIRECT
network: Connecting http://3.94.247.54:80/ with proxy=DIRECT
com.sun.deploy.net.cookie.CookieUnavailableException: No registered plugin for applet ID 9
      at sun.plugin2.main.client.MessagePassingExecutionContext.doCookieOp(Unknown Source)
      at sun.plugin2.main.client.MessagePassingExecutionContext.getCookie(Unknown Source)
      at sun.plugin2.main.client.PluginCookieSelector.getCookieFromBrowser(Unknown Source)
      at com.sun.deploy.net.cookie.DeployCookieSelector.getCookieInfo(Unknown Source)
      at com.sun.deploy.net.cookie.DeployCookieSelector.get(Unknown Source)
      at sun.net.www.protocol.http.HttpURLConnection.setCookieHeader(Unknown Source)
      at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
      at java.net.HttpURLConnection.getResponseCode(Unknown Source)
      at com.gepower.d400.communication.SyncRequest.execute(SyncRequest.java:111)
      at com.gepower.d400.model.config.ConfigurationManager.commitChanges(ConfigurationManager.java:246)
      at com.gepower.d400.view.config.ConfigurationController$CommitAction.doLongOperation(ConfigurationController.java:676)
      at com.gepower.d400.swing.BusyThread.run(BusyThread.java:103)

Could it be that the CommitAction Thread does not have time to complete before the change of Applet ?

Paolo
0
 

Author Closing Comment

by:ptreves
ID: 36904266
Need to derive from the proper controller.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses
Course of the Month11 days, 19 hours left to enroll

752 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