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
Solved

Saving dirty data from Applet

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 …
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 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 about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

856 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