cancel
Showing results for 
Search instead for 
Did you mean: 

Singleton node is null

Former Member
0 Kudos

Hello,

I have the following context node structure using NWDS 7.1 SP07:

Context (Root)

Subst (model node, singleton, collection cardinality 0..n, selection cardinality 0..1)

Org (model node, singleton, collection cardinality 0..n, selection cardinality 0..1)

During wdDoInit of the controller, I want to call getNodeInfo() of Org node to set the value set. At this time, there is still no Subst node element initialized.

Debugging, I get wdContext.nodeSubst() being not null, whereas wdContext.nodeOrg() is null. I thought a singleton node would never be null? (see my post one year ago).

With NWDS 7.0 SP12, when running the same code node Org is not null. Note that the WebDynpro project is an original 7.0 project which runs now under 7.1, but WebDynpro components have not been migrated as migration is not generally recommended by SAP.

Regards,

Josef

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hello,

discussed this problem with a context expert via OSS.

The problem is that in 7.1 mapped nodes do not have a singleton property of their own, but share it with the origin node. The advantage is that there cannot be any contradictions anymore between origin and mapped node.

But: The default value in coding is false in contrast to the default value in IDE. As long as the mapping has not finished initialization, the singleton value is still false. Mapping is initialized after wdDoInit() of the child component has finished and control returns to the using WD component. After that you can use the singleton property.

In 7.0 you could use the property in wdDoInit() of the used component.

Sanyev, thanks for showing the differences between children attributes in node and node.getNodeInfo(). The children in nodeInfo are always there even if not initialized.

Regards,

Josef

Edited by: Josef Vogler on Feb 5, 2009 2:11 PM

Edited by: Josef Vogler on Feb 5, 2009 2:44 PM

Former Member
0 Kudos

Ayyapparaj,

the code fails before any Subst element is initialized, that is, before a supply function for the child node Org would be called. As a singleton node must never be null, it should work whether there is any data or not. And it worked for more than a year in WD 7.0

I think something with the context mapping might have been broken during migration as I get different Java objects in debugger for the objects in the node, but can't find it at the moment.

Thanks and regards,

Josef

Former Member
0 Kudos

Hello Sanyev,

thank you for your detailed explanation. I saw in debugger the difference between wdContext.getNodeInfo().getChild("Name") and wdContext.nodeChild() and that for the former all children exist whereas the latter might be null. I'll try to get the node info of the child node to set the value sets etc. It would be fantastic if that works. Up to now we checked for the existence of child elements before setting value sets.

Please give me a some time to evaluate that.

Thanks again

Josef

Former Member
0 Kudos

Hi,

Are you using any supply functions?

Regards

Ayyapparaj

sanyev
Active Participant
0 Kudos

Hi Josef,

Make sure when you are using wdContext.getNodeInfo().getChild("Name") you have to follow the exact hierarchy structure. ie wdContext.getNodeInfo().getChild("Subst") will not work. You have to use wdContext.getNodeInfo().getChild("Reg").getChild("Subst") to reach the node Subst info. Where as wdContext.nodeSubst() will work directly because there are auto generated code for reaching the node directly.

Regards,

Sanyev

Former Member
0 Kudos

I had a deeper look into the variables content of the node Subst in debugger and found the children node Org to be non-singleton. ("node" is the Subst node)

node.nodeInfo.children[5].name is "Org"

node.nodeInfo.children[5].singleton is false

I opened the component controller file with a text editor and found no entry for the singleton attribute of node Org. Therefore I assume that this is set to the default value "singleton = true".

Note that this node is mapped over the Component Interface Controller to another Component Controller. Debugging the Subst node there shows

node.nodeInfo.children[2].name is "Org"

node.nodeInfo.children[2].singleton is true

Debugging interface controller shows

node.nodeInfo.children[2].name is "Org"

node.nodeInfo.children[2].singleton is false

So difference seems between the origin component controller and mapped interface controller.

When viewing properties dialog, all nodes in both component controllers and interface controller have singleton = true, cardinality = 0..n, selection cardinality 0..1. All nodes in interface controller have isInput = true.

Why does it seem that singleton is changed during runtime?

Regards,

Josef

sanyev
Active Participant
0 Kudos

Hi Josef Vogler,

When you are viewing the context with a debugger you see the internal working. It might change from version to version. Singleton is a concept introduced for performance reason.

Imagine a webdynpro application showing sales order and its line items. Assume a single sales order has 10 line items and in the system there are altogether 100 sales orders. If the line item is a non singleton node then for every sales order there should be 10 line items in memory. So altogether 100*10 = 1000 entries in memory. If line item is a singleton node then there will be 100(Sales order) + 10(line item for the lead selected sales order) = 110 entries in memory. That is a huge savings in memory. Hence SAP encourages users to use singleton nodes.

So how it is internally done, just leave it to SAP. So viewing the singleton values in the debugger might not give you a clear picture.

In you earlier post you mentioned about a node begin null at runtime and relating that to singleton nodes. I don't think singleton has anything to do with a node being null. If you create a node in the context and call wdContext.nodeName() ideally it should never be null. Even if there is no data It should return you the node Instance with an empty collection. It will still have all the metadata info of the node.

If you are trying to set some metadata infomation you can get the nodeInfo by using the following api. wdContext.getNodeInfo().getChild("Name").getChild("Name1"); etc...

If you use wdContext.nodeName1().getNodeInfo() there is a possibility for the autogenerated code for nodeName1() to break and return null.

So as you mentioned earlier if wdContext.nodeSubst().getNodeInfo(); returning null is your only problem then using this

wdContext.getNodeInfo().getChild("Reg").getChild("Subst"); should solve the problem. I don't thing investigating further into the working of Singleton is going to do any good.

Hope this helps,

Sanyev

Former Member
0 Kudos

Sorry, the formatting characters have been removed while posting this thread. The context structure looks like this:

Subst is child node of Context (Root)

Org is child node of Subst