Hi,

I have a closable tab (with the little cross image on the tab). After i click the cross to close the tab i chec on preTabClosed event if changes occurred. If i detect that changes have occured, than i raise an alert asking what to do - commit changes (and close the tab) - ignore changes (and close the tab) - cancel the close action and return to the tab!

But, how do i cancel the close action? Even if i raise an exception, the tab will be closed. How do i stop the close tab event? (you got it working in the Formspider IDE, when you close a changed xml editor tab, you get the question, and the cancel works ok, the tab will not be closed)

Thanks again, Michiel

asked 02 Jul '12, 13:06

Michiel%20A's gravatar image

Michiel A
5161544
accept rate: 13%


Hi Michiel,

The XML Editor component is specialized for Formspider IDE application. It has different events from TabbedPanel. TabbedPanel has PreTabClosed/PostTabClosed events which runs before/after removing a tab from the TabbedPanel.

Here is how you can do it: You may get all tab attributes on preTabClosed event and add them to session;

procedure preTabClosed is
  v_closedTabName_tx   varchar2(4000);
  v_tabbedPanelName_tx varchar2(255) := 'mainPanel';
begin  
  -- save current tab name
  api_session.add('currentTabName',api_tabbedpanel.getcurrenttabname(v_tabbedPanelName_tx));

  -- get closed tab name
  v_closedTabName_tx := api_tabbedpanel.getclosedtabname(v_tabbedPanelName_tx);
  api_session.add('closedTabOrder',
                  api_tabbedpanel.gettaborder(v_tabbedPanelName_tx,v_closedTabName_tx));
  api_session.add('closedTabName', v_closedTabName_tx);
  api_session.add('closedTabTitle', 
                  api_tabbedpanel.gettabtitle(v_tabbedPanelName_tx ,v_closedTabName_tx));
  api_session.add('closedTabPanelName',
                  api_tabbedpanel.gettabpanel(v_tabbedPanelName_tx   ,v_closedTabName_tx));
  api_session.add('closedTabClosable',                                      
                  api_tabbedpanel.istabclosable(v_tabbedPanelName_tx ,v_closedTabName_tx));
  api_session.add('closedTabVisible', 
                  api_tabbedpanel.istabvisible(v_tabbedPanelName_tx  ,v_closedTabName_tx));
  api_session.add('closedTabVisibleEnabled', 
                  api_tabbedpanel.istabenabled(v_tabbedPanelName_tx  ,v_closedTabName_tx));

end;

And add same tab on postTabClosed event using the attributes on session and then show the alert you want;

procedure postTabClosed is
  v_closedTabName_tx    varchar2(4000);
  v_tabbedPanelName_tx  varchar2(255) := 'mainPanel';
  v_alertName_tx        varchar2(255) := 'alert';
begin
  -- add the closed tab
  v_closedTabName_tx := api_session.getvaluetx('closedTabName');
  api_tabbedPanel.addtab(in_tabbedpanelname_tx => v_tabbedPanelName_tx
                        ,in_order_nr           => api_session.getvaluenr('closedTabOrder')
                        ,in_tabname_tx         => v_closedTabName_tx
                        ,in_title_tx           => api_session.getvaluetx('closedTabTitle')
                        ,in_panelname_tx       => api_session.getvaluetx('closedTabPanelName')
                        ,in_closable_yn        => api_session.getvaluetx('closedTabClosable')
                        ,in_visible_yn         => api_session.getvaluetx('closedTabVisible')
                        ,in_enabled_yn         => api_session.getvaluetx('closedTabVisibleEnabled'));

  -- if the closed tab was the current tab, we have to set the newly added tab as current
  if api_session.getvaluetx('currentTabName') = v_closedTabName_tx then
    api_tabbedpanel.setcurrenttab(v_tabbedPanelName_tx, v_closedTabName_tx);
  end if;

  -- show the alert
  api_alert.show(v_alertName_tx);

end;

On close event of the alert, you may remove the tab or whatever you want;

procedure alertOnClose is
  v_response_nr        number;
  v_closedTabName_tx   varchar2(4000);

  v_tabbedPanelName_tx varchar2(255) := 'mainPanel';
  v_alertName_tx       varchar2(255) := 'alert';
begin
  v_closedTabName_tx := api_session.getvaluetx('closedTabName');
  v_response_nr := api_alert.getresponse(v_alertName_tx);
  case v_response_nr
    when api_alert.button1 then -- Yes
      null; -- your business logic here
    when api_alert.button2 then -- No
      api_tabbedpanel.removetab(v_tabbedPanelName_tx, v_closedTabName_tx);
    else -- Cancel
      null;
  end case;
end;

Regards

link

answered 03 Jul '12, 05:14

Samet%20Basaran's gravatar image

Samet Basaran
1372
accept rate: 24%

Hi Samet,

Ok, that will work, thanks

Michiel

(03 Jul '12, 08:05) Michiel A
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×15
×1

Asked: 02 Jul '12, 13:06

Seen: 5,000 times

Last updated: 03 Jul '12, 08:05


© Copyright Gerger 2017