cancel
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


NodeA
  |-- NodeB
  |   |-- ValueA
  |   |-- ValueB
  |   |-- ValueC
  |--ValueD
  |--ValueE

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

wdContext.nodeNodeA().invalidate();
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++) {
	nodeB.setValueA(outStrs[j][0]);
	nodeB.setValueB(outStrs[j][1]);
	nodeB.setValueC(outStrs[j][2]);
    }
   wdContext.nodeNodeA().addElement(nodeA);
}

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

Any help is appreciated.

Lori

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();
a.nodeB().addElement(b);

Armin

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"?

Armin

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();

regards,

Piyush.

Former Member
0 Kudos

Hi Lori

Here is the example

IPrivateCommentsView.INode_AElement nodeA = null;

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

wdContext.nodeNode_A().addElement(nodeA);

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

wdContext.nodeNode_B().addElement(nodeB);

nodeB.setAtt1("xyz");

nodeB.setAtt2("ABC");

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

Regards

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)'?