Solved

Saving dirty data from Applet

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
return in catch statement 1 40
count11 challenge 6 48
parentbit challenge 3 52
Unexpected HttpURLConnection connection behavior 2 52
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now