Solved

Saving dirty data from Applet

Posted on 2011-09-25
2
496 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

717 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