cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the name of a Tab at runtime

Former Member
0 Kudos

Helllo,

I am using a Tab Strip with 5 Tab pages. At runtime i want to know which tab has the focus at the moment to user hist a button.

How can i do that

Bertil

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Bind <b>selectedTab</b> property of TabStrib to context attribute. Then you can read ID of currently selected via reading context attribute and even change currently selected tab simply by assigning value to attribute.

VS

Answers (4)

Answers (4)

wanlin_hau
Explorer
0 Kudos

What does it means by "name of UI element event parameter"? Can you show us an example?

Thank you.

Former Member
0 Kudos

Some UI element events have parameters, you can find their names and types in the Javadoc of the mappingOf<event>() methods.

Armin

wanlin_hau
Explorer
0 Kudos

When we click on a Tab, we would like to fire out to another view. Attached are coding:

public static void wdDoModifyView(IPrivateRatingMainView wdThis, IPrivateRatingMainView.IContextNode wdContext,

com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

IWDTabStrip iwdTabStrip = (IWDTabStrip)view.getElement("tsRatingMain");

String selectedTab = iwdTabStrip.getSelectedTab();

crrsLogger.info("selectedTab " + selectedTab);

wdContext.currentContextElement().setQualitativeTab(selectedTab);

}

public void onActionRatingMode(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String mode )

{

String selectedTab = wdContext.currentContextElement().getQualitativeTab();

crrsLogger.info("onActionRatingMode selectedTab " + selectedTab);

if (selectedTab.equals("tabQualitative"))

{

crrsLogger.info("Execute Fire Plug");

wdThis.wdFirePlugToLargeCorp();

}

}

But, the problem is, "wdModifyView" is always called first before "onActionRatingMode". So, the value of selectedTab is always refer to the previously called tab.

Any suggestion is kind appreciated.

Former Member
0 Kudos

How to access the selected tab ID in an action event handler after switching to a new tab:

1. Add parameter, e.g. "selectedTab", to your action event handler.

2. In wdDoModifyView(), declare an event parameter mapping for the parameter "tab" of event IWDTabStrip.onSelect:


if (firstTime)
{
  IWDTabStrip tabstrip = (IWDTabStrip)
    view.getElement(<tabstripID>);
  tabstrip.mappingOfOnSelect().addSourceMapping(
    "tab", /* name of UI element event parameter */
    "selectedTab" /* name of action handler parameter */
  );
}

Then you get the ID of the new selected tab in your action event handler through parameter "selectedTab".

Armin

Former Member
0 Kudos

Hi,

The solution that was mentioned works fine!

thanks for helping

Bertil

Former Member
0 Kudos

Hi Bertil,

In my application also I want to find out which TAB they selected for displaying the View. I tried with the sample coding I am not getting.Can I get a sample code to find out the TAB selected Event.

Thanks in Advance.

yours,

ram

Former Member
0 Kudos

You mean the ID of the currently selected tab?

See:


IWDTabStrip.getSelectedTab()

or if you need access in an event handler: Bind the selectedTab property and ask the view context for the current value.

Armin