cancel
Showing results for 
Search instead for 
Did you mean: 

"cannot bind or add elements because the node has no valid parent"

Former Member
0 Kudos

Hello All,

I keep getting the above error message. Can someone help ?

<u><b>Context Structure</b></u>

- A (Model Node)

- B (Sub Model Node of A)

++ Country (Model Attribute B)

++ Language(Model Attribute B)

<u><b>Coding</b></u>

IPrivateMainView.IAElement userInfo = wdContext.createAElement(new A());

wdContext.nodeB().addElement(userInfo);

The error stack always report that the above syntax causes the error message.

Can someone kindly let me know where I may have gone wrong ? Thank you.

from

Kwok Wei

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

It seems that you create element A but not add it to node A. You may add children (i.e. elements of B) only when all parents are bound. So the code should looks like:


IPrivateMainView.IAElement userInfo = wdContext.createAElement(new A());
/* Add parent first */
wdContext.nodeA().addElement(userInfo);
/* Next manipulate with child */
wdContext.nodeB().addElement(elementB);

VS

Former Member
0 Kudos

Hey, this was it! at least my problem is solved!

I had kind of the same structure and solved it by adding a root <i>element</i> to a root <i>node</i>:

			wdContext.nodeDB_AllData().addElement(allData);
			wdContext.nodeDB_AllData().nodeHeader().addElement(header);
			wdContext.nodeDB_AllData().nodePositions().addElement(positions);

Former Member
0 Kudos

hi,

To my understanding i think a is the parent of b .. I am wondering how u can add the parent to the child..

"cannot bind or add elements because the node has no valid parent"

means the nodeB s parent element is not created or no parent is specified...

so you have to create the parent element and then use the parent object to create the child node...

IPrivateMainView.IAElement userInfo = wdContext.createAElement(new A());

userinfo.nodeB().addElement(node B object );

Regards

Bharathwaj

Former Member
0 Kudos

Hello Bharathwaj

Thanks for the help. I am having problem with this statement "userinfo.nodeB().addElement(node B object );"

The only option that I have after userInfo. is node() ... nodeB() is not available. Am I missing something else here ?

from

Kwok Wei

Former Member
0 Kudos

hi,

Check if the sub node singleton property is set to true.. If its true we can get nodeB....

Otherwise you have supply its value using a supply function..

Regards

Bharathwaj

Former Member
0 Kudos

Hi Bharathwaj ,

The singleton property is already set to true. In fact when i try to change the supplyFunction property, a window pops up saying "A supplying relation role is already defined for this contex node. etc ......"

A wild shot here but will the cardinality make any difference ? its 0..1 for both A and B.

from

Kwok Wei

Former Member
0 Kudos

Hi,

The model node is a reference to the model object so you need to bind the node to a similar structure or table from the model object.

eg.

abc(model node)

|__def(model subnode)

|___attr_a

|___attr_b

Then you need to first bind abc node

abc ele=new abc();

wdContext.nodeAbc().bind(ele);

Then bind the def to the corresponding def node

def subele=new def();

ele.setDef(subele); or ele.addDef(subele);

Regards

Noufal

Message was edited by: Noufal Kareem

Message was edited by: Noufal Kareem

Former Member
0 Kudos

Hi,

If the sub node is singleton you should be able to access it as nodeB....I think you might be checking the property of the wrong node or u might be using the wrong parent..

And its difficult to find what the problem is as I am not sure how exactly the structure is !

Regards

Bharathwaj