Revision history [back]

click to hide/show revision 1
initial version

answered 2010-10-27 16:48:59 +0800

terrytornado gravatar image terrytornado flag of Germany

http://www.oxitec.de/

That's the way i work:

In our case we set the Tab-ID dynamically, so we must get them first to catch the onClose event. If you have a fixed name you don't need that.

     ... extends GenericForwardComposer ...

   . . .
    // the menu created Tab for this module window
    private Tab menuTab;
   . . .



    @Override
    public void doAfterCompose(Component window) throws Exception {
        super.doAfterCompose(window);

               . . .

        /**
         * Get the menu-created Tab for this module and add the EventListener
         * for 'onClose' because by onClose we will check if their are unsaved
         * data. The menuTab have a programatically created ID from the
         * menuController.<br>
         * i.e. 'tab_' + Labels.getLabel("menu.items.Orders")= 'tab_Auftraege'.
         */
        Component cmp = (Component) windowSupplierMain.getParent().getParent().getParent();
        String menuName = "tab_" + Labels.getLabel("menu.Item.Suppliers").trim();
        menuTab = (Tab) cmp.getFellowIfAny(menuName, false);
        menuTab.addEventListener("onClose", new EventListener() {

            @Override
            public void onEvent(Event event) throws Exception {
                doClose(event);
            }
        });

               . . .

    }

.

    /**
     * When the Tab is closed.<br>
     * We check if their are unsaved data by comparing the selectedBean's data
     * with the originalBean's data.
     * 
     * @param event
     * @throws InterruptedException
     */
    public void doClose(Event event) throws InterruptedException {

        // check if data is changed
        if (isDataChanged()) {

            // Show a confirm box
            final String msg = Labels.getLabel("message_Data_Modified_Save_Data_YesNo");
            final String title = Labels.getLabel("message.Information");

            MultiLineMessageBox.doSetTemplate();
            if (MultiLineMessageBox.show(msg, title, MultiLineMessageBox.YES | MultiLineMessageBox.NO | MultiLineMessageBox.CANCEL, MultiLineMessageBox.QUESTION, true, new EventListener() {
                @Override
                public void onEvent(Event evt) {
                    switch (((Integer) evt.getData()).intValue()) {
                    case MultiLineMessageBox.YES:
                        doSave(evt);
                        menuTab.onClose();
                    case MultiLineMessageBox.NO:
                        menuTab.onClose();
                    case MultiLineMessageBox.CANCEL:
                        menuTab.setSelected(true);
                        tabSupplierAddress.setSelected(true);
                        break;
                    }
                }
            }

            ) == MultiLineMessageBox.YES) {
            }

            event.stopPropagation();

        }
    }

best Stephan

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More