cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with creating a link between views dynamically

Former Member
0 Kudos

Hi All,

I'm struggling with creating a navigation link between a dynamically generated outbound plug and an existing inbound plug of an interface view in another DC.

I get a NullPointerException on the createNavigationTarget statement:


// generate outbound plug
IWDOutboundPlugInfo outboundPlug = wdThis.wdGetAPI().getViewInfo()
   .createOutboundPlug();
    	
// get reference to inbound plug
IWDInboundPlugInfo inboundPlug = wdThis.wdGetMIMENUController()
   .wdGetAPI().getComponentInfo()
   .findInComponentUsages("myUsedComponent")
   .getUsedComponent().findInInterfaceViews("MainWindowInterfaceView")
   .findInInboundPlugs("Default");
    	
// get reference to target view
IWDViewUsageInfo targetView = wdThis.wdGetMIMENUController().wdGetAPI()
   .getComponentInfo()
   .findInComponentUsages("myUsedComponent")
   .getUsedComponent().findInInterfaceViews("MainWindowInterfaceView")
   .getImplementationWindow().getDefaultRootViewUsage();
    	
// link outbound plug to inbound plug "default" of used DC
wdThis.wdGetAPI().getComponent().getComponentInfo()
   .findInWindows("MainWindow")
   .getViewUsageByID("TreeMenu")
   .createNavigationTarget(outboundPlug.getName(), targetView, inboundPlug.getName());

// fire outbound plug
wdThis.wdGetAPI().firePlug(outboundPlug, new HashMap());

I tried to debug and looks like all three parameters of createNavigationTarget are good. Is there a problem with this method? Or my code?

Please let me know if I'm missing anything.

Regards,

Roman D.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Roman

In the Web Dynpro explorer, under the window node,select the view "TreeMenu" under the window "MainWindow". In the properties tab enter the id of the window as "TreeMenu" (This id must be missing).

Hope this helps.

kk.

Answers (3)

Answers (3)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Roman,

what's exactly your use case, or why do you have to create plugs and navigation links dynamically? Perhaps there is a more simple static solution for your problem.

Best regards, Bertram

Former Member
0 Kudos

Hello Bertram,

I am adding component usages at runtime, followed by creating a link to Interface Views of those components. Since I don't know which components will become "Used DCs" at runtime, I have to create the outbound plug and links between that outbound plug and the inbound plug of Interface View at runtime.

Possibly, the problem is that my "launcher" view is embedded into a View Container of another "wrapper" view. May be Interface Views have to be embedded into that View Container prior to creating a dynamic link?

There are so many things that could go wrong here...

Thanks,

Roman

monalisa_biswal
Contributor
0 Kudos

Split the following line into multiple lines to find out exact error location.

wdThis.wdGetAPI().getComponent().getComponentInfo()

.findInWindows("MainWindow")

.getViewUsageByID("TreeMenu")

.createNavigationTarget(outboundPlug.getName(), targetView, inboundPlug.getName());

IWDWindowInfo winInfo=

wdThis.wdGetAPI().getComponent().getComponentInfo()

.findInWindows("MainWindow");

IWDViewUsageInfo viewUsageInfo= winInfo.getViewUsageByID("TreeMenu");

viewUsageInfo.createNavigationTarget(outboundPlug.getName(), targetView, inboundPlug.getName());

The error may be due to wrong Window ID or the view might not have been embeded in the window.

Former Member
0 Kudos

Thanks for your replies. I was able to get past this, but now running into another issue:

java.lang.NullPointerException: Can't set a relation role because o==null and the role cardinality is 1.

I think this has something to do with a missing plug. There is <a href="https://forums.sdn.sap.com/click.jspa?searchID=1348322&messageID=1270402">one post</a> on SDN that mentions it, but there wasn't enough info to solve the error.

When I debug, all four objects involved (targetView, sourceView, outboundPlug, and inboundPlug) appear to be correct.

Any ideas what else could go wrong?

Thanks in advance!

Former Member
0 Kudos

Is your Used DC created automatically or manually?

Former Member
0 Kudos

Hi Peter,

My Used DCs are declared at design time in the developer studio.

Roman