on 06-15-2009 11:50 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Did you try the copy node method??
This will copy the entire node corresponding to Table to A to Table B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.