cancel
Showing results for 
Search instead for 
Did you mean: 

tableUI with multiple rows as input element.

Former Member
0 Kudos

hi Expert,

I am working on an application. Where i am enterin data in rows of table A.

I have used two tables A and B. I want to move all data from table A to B.

the code i have used is

for(int i=0; i<size; i++)

{

wdContext.nodeA.getElementAt(i);

elm = wdContext.createBElement();

elm.setPlace_Form(wdContext.nodeB().getBElementAt(i).getPlace_Form());

elm.setPlace_to(wdContext.nodeB().getBElementAt(i).getPlace_Form());

wdContext.nodeA().addElement(elm);

}

the problem i facing is when this code works it takes the last row and displays the same row in the entire table B instead of all the rows.

I got some hint to use arrays but not able to sucessfully try it please help with any code sample.

Regards,

Sanjyoti.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I was having the similar requirement & i used the the below code.

//Data to be copied from node Claim_Adv_Trn_Appr to ClaimData.

for ( int x = 0 ; x < wdContext.nodeClaim_Adv_Trn_Appr().size() ; x++ )

{

IPrivateOverviewView.IClaim_Adv_Trn_ApprElement IDNode = wdContext.nodeClaim_Adv_Trn_Appr().getClaim_Adv_Trn_ApprElementAt(x);

IPrivateOverviewView.IClaimDataElement IDValues =

wdContext.nodeClaimData().createClaimDataElement();

IDValues.setEmpNo(IDNode.getPernr());

IDValues.setClaimNo(IDNode.getReference());

wdContext.nodeClaimData().addElement(IDValues);

}

This will definitely solve your problem.

Regards

Shruti

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Here there are some mismatch of table A and B. May be a typing mistake

please make sure that you have to pass data from table A to table B

so the code should be

size = wdContext.nodeA().size();

elm = IBElement();

for(int i=0; i<size; i++)

{

elm = wdContext.createBElement();

elm.setPlace_Form(wdContext.nodeA().getAElementAt(i).getPlace_Form());

elm.setPlace_to(wdContext.nodeA().getAElementAt(i).getPlace_Form());

wdContext.nodeB().addElement(elm);

}

also make sure that the cardinaily is same for both the table 0-n.

still If you are not getting the output properly, put some comments in between, and try to debug.

AM

Former Member
0 Kudos

may be yes, as its working fine now.

thankyou and thread closed.

Regards,

Sanjyoti.

Former Member
0 Kudos

hi

try with this code

for(int i=0; i<size; i++)

{

wdContext.nodeA.getElementAt(i);

elm = wdContext.createBElement();

elm.setPlace_Form(wdContext.nodeB().getBElementAt(i).getPlace_Form());

elm.setPlace_to(wdContext.nodeB().getBElementAt(i).getPlace_Form());

}

wdContext.nodeA().addElement(elm);

you have to bind or add the elements outside the loop. this will help otherwise it would

only get the last elements and add to the node .

pravesh_verma
Active Contributor
0 Kudos

Hi Sanjyoti,

This just requires a single line of code:


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

this will automatically copy all the node elements from one to another.

Also please read the documentaion of wdcopyservice:


/*
   Copies all elements from source to target. The
   method is the same as
   copyElements(IWDNode, IWDNode, boolean)with

   @param source The source node
   @param target The target node
   @throws RuntimeException if <code>target</code> is a model node and 
   source is not a model node holding the same class.
   */

  public static void copyElements(IWDNode source, IWDNode target) {
    instance.copyElements(source, target);
  }

I hope this helps to solve the issue. i would suggest that instead of writing the code, just use this approach which is a standard to copy elements from one node to another.

Thanks and Regards

Pravesh

Former Member
0 Kudos

Hi all,

I had tried the WDCopyService code but it also gives me the same result that is only the last line is repeated in the new table node.

Regards,

Sanjyoti.

Former Member
0 Kudos

Hi,

Can you please post the cardinality & other properties of both the nodes.

Regards,

Charan

Former Member
0 Kudos

I feel this might be with the Cardinality issue.

Try making 0..n as the cardinality for both Node A and Node B.Then try the code and let us know the output

Former Member
0 Kudos

Hi,

First Table : Node A: Where user enters the data

Second Table: Node B: All the data entered by user should be displayed in this node

Now write the code as below:

int sizeNodeA=wdContext.nodeA().size()

for(int i=0; i<sizeNodeA; i++)
{

IPrivateTestView.INodeBElement element = wdContext.createBElement();

element.setPlace_Form(wdContext.nodeA().getAElementAt(i).getPlace_Form());
element.setPlace_to(wdContext.nodeA().getAElementAt(i).getPlace_to());

//Here you need to add the newly created element to node B. You should not bind
wdContext.nodeB().addElement(element);

}

It works.

Or

You can use WDCopyservice to copy the elements from one node to another node having the same attributes.

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

Regards,

Charan

Former Member
0 Kudos

Hi,

Did you try the copy node method??

This will copy the entire node corresponding to Table to A to Table B