cancel
Showing results for 
Search instead for 
Did you mean: 

Copy selected node Elements to a Value Node

Former Member
0 Kudos

Hello,

i'm trying to copy some selected Elements from a Model Node to a Value Node.

Can i perform somethong like:


wdContext.ValueNode.addElement(wdContext.ModelNode.currentElement);

It schould perfom something like a user assignment. One table at the Portal schows all available users another tabel schould contain all assigned user. A Button schould assign them. So I need to copy the users from one table to another.

I'm happy about every helpul hint.

Greets Norman

Message was edited by:

Norman Trapp

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member182372
Active Contributor
0 Kudos

Norman, lets say we have 2 model nodes ModelNode1 and ModelNode2 bound to the same model class (ModelClass). You can use code:


IWDNode node1 = wdContext.nodeModelNode1();
IWDNode node2 = wdContext.nodeModelNode2();
final int size = node1.size();
final int leadSelection = node.getLeadSelection();

Collection selectedNodes = new ArrayList(size);
for (int i = 0; i< size; i++)
{
	final IWDNodeElement element = node1.getElementAt( i );
	
	if( leadSelection == i || node1.isMultiSelected( i) )
		selectedNodes.add(element.model());
}

node2.bind(selectedNodes);

Former Member
0 Kudos

Hello Maksim,

thanks but your solution ends in the following exception:

com.sap.tc.webdynpro.progmodel.context.ContextException: DataNodeInfo(MyView.myValueNode): you must bind NodeElements to a value node

Any suggestions?

Regards Norman

Message was edited by:

Norman Trapp

Former Member
0 Kudos

You have to create and add new elements in the target node. For copying the attribute values, the utility methods in class WDCopyService are useful.

Something like:


IWDNode source = ...;
I<Target>Node target = ...;
for (int i = 0; i < source.size(); ++i)
{
  if ( source.getLeadSelection() == i || source.isMultiSelected(i) )
  {
    IWDNodeElement src = source.getElementAt(i);
    IWDNodeElement tgt = target.create<Target>Element();
    target.addElement(tgt);
    WDCopyService.copyCorresponding(src, tgt);
  }
}

Armin

Former Member
0 Kudos

Hello Armin,

your solution seems good, but i cnat see any result. After implementation nothing happens.

I hope i haven't forget anything.

Greetings

Norman

Former Member
0 Kudos

Where don't you see any results, in a UI element or when debugging / printing the context node content?

Armin

Former Member
0 Kudos

Sorry ,

I was a bit unprecise . The valueNode wich contains the elements in bound to a UIElement (Table).

In the table I cant see any result.

Gruß

Norman

Former Member
0 Kudos

Can you first debug the code that fills the value node and check if there are elements added at all?

If yes, check the data binding of the table.

Armin

Former Member
0 Kudos

Hello Armin,

yes elements where added, but they are empty. They have no content. The result table is growing, but not entries are visible. I tried to check out why, but my WD Knowledge is at the end to find out what happens here.

Greets

Norman

Former Member
0 Kudos

The copyCorresponding method makes certain assumptions on the attribute names and types to be copied. Can you tell how your context structure looks like? Probably copyCorresponding cannot match the attributes to be copied.

Armin

Former Member
0 Kudos

Hello Armin,

i'll try to explain. I created a ModelNode based on a R/3 FM. I get an export Table from the FM. These table is bound to a UI Element (table) withe create binding.

I need the tabel or parts of the table as import Parameters for another FM.

Actually i'll try to store the needed parts in a ValueNode i created, with structure binding to the ModelNode structure. IMHO these structures must be the same.

Or ist wrong?

My ModelNode Structure looks like a common ModelStructure with an export tabel

My VlaueNode Structure looks like the ModelStructure export tabel.

I hope you have enough info's to see whats going wrong there.

Thanks

Norman