cancel
Showing results for 
Search instead for 
Did you mean: 

Creation of new element in Model Node

Former Member
0 Kudos

Dear All,

I am facing one problem, I have two model node. I want to copy one model node to other model node.while copying its giving error saying the you can bind the element, coz target node doesn't have valid parent.

Pl don't suggest me work on Value node.

Can i create a element in model node at run time.

Thanks & Regards

Manoj Sahoo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Just clone the model object of node 1 then bind it to node 2. If you get an error because parent of node 2 is not valid you will have to create a suitable model object for it (containing the cloned object before mentioned, probably thanks to the use of an add or set method with the cloned object as parameter) and make a bind.

Former Member
0 Kudos

Thanks , but can you please explain me more with example.

Answers (2)

Answers (2)

Former Member
0 Kudos

I have solved this problem by creating dummy object for both request node and response node and bind them. This will create a dummy element for me , after that i can copy the node with out any error.

Thanks to all of you.

Former Member
0 Kudos

Hi manoj,

It seems the node u r trying to copy is a child node & no element exists for the parent node. Execute the model, so that ur parent node is filled. After that u can copy the node.

regards

Sumit

Former Member
0 Kudos

I have Model Node say

ANode(Model Node)

---Attribute1

---Attribute2

BNode(Model Node)

-


Attribue1

-


Attribute2

ANode having 10 elements

BNode having 0 elements

I am trying to copy from ANode to BNode

and getting error.

Former Member
0 Kudos

Hi,

What is the code you have written to copy the anode to bnode.

thanks & regards,

Manoj

Former Member
0 Kudos

WDCopyService.copyElements(wdContext.nodeA(),wdContext.nodeB());

its working fine if B has any element previously , its not working only when B doesn't have any element.

Former Member
0 Kudos

Hi Manoj,

Model node properties :

1.A context model node makes a model object look like any other context node. I.E. it gives the model object an API that is very similar to a value node.

2. A model node is not considered valid until it is bound to a corresponding model object. Therefore, a model node always inherits its metadata from the model object to which it is bound.

3. The element collection in a model node does not hold the actual runtime data! Instead, it holds a list of references to the relevant model object instances.

If u check the 2nd property, u will find the cause of ur exception. As u have already told, don't suggest to use value nodes, i don't have any other comment.

regards

Sumit

Former Member
0 Kudos

Do this:

Collection objects = (Collection)ANode.modelObject().clone();

BNode.bind(objects);

You will have to implement the clone method by yourself if not implemented by the model object. If you want to just copy the references and not the objects (modifications in one node will be reflected in the other too) just do:

BNode.bind(ANode.modeObject());

Edited by: Eduardo Cabezas López on Jan 22, 2008 4:00 PM