Showing results for 
Search instead for 
Did you mean: 

Populating a context

Former Member
0 Kudos

I've search the forum, but haven't found anything to address this issue.

I have a context of

  |-- NodeB
  |   |-- ValueA
  |   |-- ValueB
  |   |-- ValueC

I have 1-N of NodeA with it containing 1-N NodeB.

I'm trying to prepopulate the context on startup but can't get NodeB inserted into NodeA. I.e. my code looks like this

for (int k = 0; k < some_info.length; k++) {
    INodeAElement nodeA = wdContext.createNodeAElement();
    nodeA.setValueD((String) some_info[k][0]);
    nodeA.setValueE((String) some_info[k][1]);

    String[][] outStrs = (String[][]) some_info[k][2];
    INodeBElement nodeB = wdContext.createNodeBElement();
    for (int j = 0; j < outStrs.length; j++) {

How do I get the 1-N nodes of NodeB associated with NodeA?

Any help is appreciated.


Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Is NodeB a singleton or a non-singleton?

If it is a non-singleton, every element of NodeA has its own instance of a NodeB which can be accessed using

NodeAElement a = ...;
NodeBElement b = a.nodeB().createNodeBElement();


Former Member
0 Kudos

NodeB is a non-singleton (by your description). NodeA can contain 1-N NodeBs.

I tried to follow your code but when I type 'a.nodeB()' I get an error. WebDynPro reports that that method does not exist.

Former Member
0 Kudos

Have you set "typedAccessRequired" to true?

Is "a" of type "NodeAElement"?


Former Member
0 Kudos

The typeAccessRequired was set to true.

BUT! I'd forgotten to change the selection (0..1->1..N) and singleton (true->false) properties. Now I can access NodeB and modify it.

Thanks for the help!

Lori <*>

Former Member
0 Kudos

hello Lori,

i think u want to add some child node elements inside a parent node element. similarlly like one school inside which there are many children.

now create the parent element using this code:

IPrivateView.IAElement pele = wdContext.nodeA().createAElement(); // instead of wdContext.createAElement();

now to add a child node element inside this parent element:

IPrivateView.IBElement cele = pele.nodeB().createBElement();



Former Member
0 Kudos

Hi Lori

Here is the example

IPrivateCommentsView.INode_AElement nodeA = null;

nodeA = wdContext.nodeNode_A().createNode_AElement();


IPrivateCommentsView.INode_BElement nodeB = wdContext.nodeNode_A().nodeNode_B().createNode_BElement();




nodeA.setAtt_A("Node A");

You can loop the above code for n times. Each time you create a node A inside the loop create a node B after Node A in the loop


NagaKishore V

Former Member
0 Kudos

I don't quite understand your code NagaKishore. I want to added 1-N elements of type NodeB to NodeA. And was 'setAtt_A' a 'setAttribute("NodeA", NodeB)'?