[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Saving dirty data from Applet

Posted on 2011-09-25
2
Medium Priority
?
505 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

650 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