[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

Java Applet

Hello,

I am working on a J2SE web application that divides the browser window in 2 frames. The top frame called the powerbarframe has a series of Javascript Object buttons that control the display of various applets in the bottom frame called the display frame.

The bottom frame itself is composed of JOptionPane with several tabs. It has a Java method that prompts the user if he wants to discard changes before loading a new applet in response to a tab change. See function below:

    public void tabWillBeSelected(TabSelectionWillChangeEvent e) {
    //public void tabWillBeSelected(TabSelectionWillChangeEvent e) {
          //EventObject ApplicationEvent TabSelectionWillChangeEvent - ChangeEvent
        // If configuration is modified, show dialog
        if (configurationManager.isModifedConfigurations()) {

            // ask if they really want to discard changes
            int selection = JOptionPane.showConfirmDialog(getView(), messages.getString("ConfigTabChangeConfirmMsg"),
                    messages.getString("ConfigTabChangeConfirmMsgTitle"),
                    JOptionPane.YES_NO_OPTION);

            if (selection != JOptionPane.YES_OPTION) {
            e.setCanceled(true);
            } else { // Discard changes
                configurationManager.setModifedConfigurations(false);
            }
        }
    }

If the user wants to discard changes, the event is cancelled.
I want to implement the same functionality if the user click one of the Javascript Object buttons from the powerbar frame. I am thincking of writing a methode from the applet shutdown() method. The problem is that it does not allow the the user to save he configuration changes if he wants to:

see code snipped below:

    public void shutdown() {
        if (configurationManager.isModifedConfigurations()) {
              int selection = 999;
              
            // ask if they really want to discard changes
            selection = JOptionPane.showConfirmDialog(null, messages.getString("ConfigTabChangeConfirmMsg"),
                    messages.getString("ConfigTabChangeConfirmMsgTitle"),
                    JOptionPane.YES_NO_OPTION);
           
            if (selection == JOptionPane.YES_OPTION) { //Discard Changes
                configurationManager.setModifedConfigurations(false);

                super.shutdown();
                removeBindings();
                stopCurrentApplet();
            } else if (selection == JOptionPane.NO_OPTION) { //Save changes
                  //find way to abort
                  System.out.println("Catch ApplicationEvent !!! Update Mutable Table fields.");
//                  abort();
//                  currentApplet.stop();
                  return;
            }
        }
    }

            currentApplet.stop();
            if (logger.isDebugEnabled()) {
                logger.debug("Destroying prior applet " + currentApplet.getClass());
            }
            currentApplet.destroy();


Any suggestions ??

Paolo
0
ptreves
Asked:
ptreves
1 Solution
 
ptrevesAuthor Commented:
Need to implement proper controller.
0

Featured Post

Cyber Threats to Small Businesses (Part 1)

This past May, Webroot surveyed more than 600 IT decision-makers at medium-sized companies to see how these small businesses perceived new threats facing their organizations.  Read what Webroot CISO, Gary Hayslip, has to say about the survey in part 1 of this 2-part blog series.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now