cancel
Showing results for 
Search instead for 
Did you mean: 

TabStrip: Get selectedTab?

Former Member
0 Kudos

Hello everybody,

how do I get the selectedTab, when the onSelectAction on the TabStrip is processed?

Thanks a lot, Regards Mario

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Bind the "selectedTab" property to a context attribute. Then you can always get the ID of the selected tab from this attribute.

Otherwise, you have to define a parameter mapping for the "onSelect" parameter "tab".

Armin

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Mario,

You can have a context value attribute (of type String) which can store the current id of the selected tab.

In the wdDoModifyView method of the view,

you can do:

IWDTabStrip tab = (IWDTabStrip)view.getElement("<tab strip id>");

wdContext.currentContextElement.set<value attribute>(tab.getSelectedTab());

From the context you can get the currently selected tab id.

RK

Former Member
0 Kudos

Hi Radha,

as far as I know, the wdDoModifyView is processed after the action onSelect. So it seems that I do not get the last selected tab?

Thanks Mario

Former Member
0 Kudos

Hi Mario,

Please bind a context Attribute of type Sting to the Selected Tab property of the TabStrip.

wdContext.currentContextElement.get<attr.>();

would return the selected tab.

Noufal

Former Member
0 Kudos

Yes, Mario, you are correct -- Radha's example will not work.

But my example will work -- parameter binding will be performed before view is shown to user for first time (so before any action on this view).

Btw, approach with context binding (see Armin's and Noufal's posts) is simpler and quicker. Use parameter mapping only if you need previous tab ID as well.

VS

Former Member
0 Kudos

Marion,

1. Declare 2 string parameters for onSelect action handler, say "paramNewTab", "paramPrevTab", type string.

2. Add the following to wdDoModifyView:


if (firstTime)
{
  final IWDTabStrip aTabStrip 
    = (IWDTabStrip)view.getElement("<tabStripID>");
  aTabStrip.mappingOfOnSelect().addSourceMapping
  (
    "tab" /*IWDTabStrip.IWDOnSelect.TAB*/, 
    "paramNewTab"
  );  
  aTabStrip.mappingOfOnSelect().addSourceMapping
  (
    "oldTab" /*IWDTabStrip.IWDOnSelect.OLD_TAB*/, 
    "paramPrevTab"
  );  
}

3. In action handler "paramNewTab" variable will contains ID of selected tab.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com