cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the selected tab ID at runtime?

Former Member
0 Kudos

I am wondering how to get the tab id of the currently selected tab at runtime? I have read other posts suggesting creating a string context attribute, then set the "selectedTab" property of the tabstrip to this attribute. I have done this, but it is not working. Is there something else I am missing?

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Sarah, bind tab`s property "selectedTab" to context attribute and you can access it in any place of view controller. Also try to define onSelect action and event handler (with no implementation).

Former Member
0 Kudos

I have done this. I set the selectedTab property to TabSelection (which is the name of my context attribute). However, it still does nothing. When I click a different tab, I get a null pointer exception also.

Former Member
0 Kudos

Can you post the complete stacktrace?

Armin

former_member182372
Active Contributor
0 Kudos

What about empty event handler for onSelect? Did you define it?

Former Member
0 Kudos

Exception occured during processing of Web Dynpro application local/CustomerEncounter/CustomerEncounterApplication. The causing exception is nested.

[EXCEPTION]

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException

at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.handleUIElementEvent(HtmlClient.java:964)

at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.updateEventQueue(HtmlClient.java:379)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.prepareTasks(AbstractClient.java:93)

at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:294)

at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:752)

at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:705)

at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:261)

at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:154)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)

at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)

at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:160)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)

at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

Caused by: java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.handleUIElementEvent(HtmlClient.java:956)

... 25 more

Caused by: java.lang.NullPointerException

at com.sap.tc.webdynpro.clientserver.data.DataContainer.removePendingUserInput(DataContainer.java:1238)

at com.sap.tc.webdynpro.clientserver.data.DataContainer.setString(DataContainer.java:1051)

at com.sap.tc.webdynpro.clientserver.uielib.standard.impl.TabStrip.setSelectedTab(TabStrip.java:626)

at com.sap.tc.webdynpro.clientserver.uielib.standard.uradapter.TabStripAdapter.onTabSelect(TabStripAdapter.java:2750)

at com.sap.tc.webdynpro.clientserver.uielib.standard.uradapter.TabStripAdapter.onTABCHANGE(TabStripAdapter.java:1184)

... 30 more

former_member182372
Active Contributor
0 Kudos

Does context node with attribute bound to UI element`s property (selectedTab) have elements?

according to this


            public void removePendingUserInput(AttributePointer pointer)
            {
/*1234*/        externalFormat.remove(pointer);
/*1235*/        internalFormat.remove(pointer);
/*1238*/        pointer.changed();
            }

seems like pointer is null which means that "attribute" instance doesn`t exist.

Former Member
0 Kudos

It seems like if I leave the following line of code out, it works, but as soon as I try to get the value of the attribute it crashes (TabSelection is the attribute name):

String tab=wdContext.currentTableNodeElement().getTabSelection();

I have the attribute also tied to a label so I can see what the value is, and there it is correctly outputting the tab ID. But for some reason, this code causes it to crash.

What I want to do is get the value so I can then use it to determine the next steps.

former_member182294
Active Contributor
0 Kudos

Hi Sarah,

Looks like you have assigned selectedTab (TabSelection) to custom node attribute. In your case TableNode -> TabSelection.

The cardinality of the node might be 0..1 or 0..n. Thats the reason its throwing NullpointerException.

You can move the TabSelection attribute from TableNode to root node and assign it to selectedTab property, it will work fine.

Regards

Abhilash

former_member182372
Active Contributor
0 Kudos

> The cardinality of the node might be 0..1 or 0..n.

1..1 and 1..N too if it is value node.

Former Member
0 Kudos

Thanks for the help. I moved the attribute to the root node, and that fixed my problem.

Answers (0)