cancel
Showing results for 
Search instead for 
Did you mean: 

shortcut for copying elements in node

Former Member
0 Kudos

hi all,

can any one suggest me a better method for copying a node element to a new node.I am using the following code.. is there any alternative..?

String string = wdContext.nodeFlight_List().getFlight_ListElementAt(lead).getAirline();

String string1 = wdContext.nodeFlight_List().getFlight_ListElementAt(lead).getAirportfr();

String string2 = wdContext.nodeFlight_List().getFlight_ListElementAt(lead).getAirportto();

String string3 = wdContext.nodeFlight_List().getFlight_ListElementAt(lead).getCityfrom();

String string4 = wdContext.nodeFlight_List().getFlight_ListElementAt(lead).getCityto();

IPrivateResult_view.IDummyElement ele = wdContext.nodeDummy().createDummyElement();

ele.setAirline(string);

ele.setAirportfr(string1);

ele.setAirportto(string2);

ele.setCityfrom(string3);

ele.setCityto(string4);

wdContext.nodeDummy().addElement(ele);

*********************************************************************************************in next view***

IPrivateTable_view.IDummyElement ele = wdContext.createDummyElement();

ele.setAirline(wdThis.wdGetWd_dc_custom_componentController().wdGetContext().currentDummyElement().getAirline());

ele.setAirportfr(wdThis.wdGetWd_dc_custom_componentController().wdGetContext().currentDummyElement().getAirportfr());

ele.setAirportto(wdThis.wdGetWd_dc_custom_componentController().wdGetContext().currentDummyElement().getAirportto());

ele.setArrdate(wdThis.wdGetWd_dc_custom_componentController().wdGetContext().currentDummyElement().getArrdate());

ele.setArrtime(wdThis.wdGetWd_dc_custom_componentController().wdGetContext().currentDummyElement().getArrtime());

ele.setCityfrom(wdThis.wdGetWd_dc_custom_componentController().wdGetContext().currentDummyElement().getCityfrom());

ele.setCityto(wdThis.wdGetWd_dc_custom_componentController().wdGetContext().currentDummyElement().getCityto());

wdContext.nodeDummy().addElement(ele);

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos
former_member197348
Active Contributor
0 Kudos

Hi Jithin,

You can use wdCopyService methods like this. But this copies entire source node (all the node elements) to target node.

If it suits your requirement, you can copy like this:

wdCopyService.copyElements(wdContext.nodeFlight_List(),wdContext.nodeDummy() );

Regards,

Siva

Former Member
0 Kudos

hi siva,

can u please tell me how to copy only the lead selected values..

former_member192434
Active Contributor
0 Kudos

Hi

Use this code

int listSize = wdContext.node<Node name>().size();

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

{

if(wdContext.node<Node name>().isSelected(i))

{

String strName = wdContext.node<Node name>().get<Node Name>ElementAt(i).get<Attribute name>();

IPrivate<View Name>.I<Node Name>Element element = wdContext.node<Node Name>().create<Node Name>Element();

element.<Attribute name>(strName );

wdContext.node<Node Name>().addElement(element);

}

}

with this code you can achive multiple selection functionality.

for single selection:

String strName = wdContext.node<Node name>().get<Node Name>ElementAt(leadSelect).get<Attribute name>();

IPrivate<View Name>.I<Node Name>Element element = wdContext.node<Node Name>().create<Node Name>Element();

element.<Attribute name>(strName );

wdContext.node<Node Name>().addElement(element);

Thanks

monalisa_biswal
Contributor
0 Kudos

hi Jithin,

Lead Selected values can be retrieved using wdContext.current<Node>Element(); statement.

So to copy lead selected values use following Statement:

wdCopyService.copyCorresponding(wdContext.current<Source Node>Element(),wdContext.current<Target Node>Element());

Hope it helps!

Mona

Former Member
0 Kudos

Hi,

Yes, you should use copyCorresponding method. So in your case (looking at your first post) the code will look like:


IPrivateTable_view.IDummyElement ele = wdContext.createDummyElement();

WDCopyService.copyCorresponding(
                    wdThis
                   .wdGetWd_dc_custom_componentController()
                   .wdGetContext()
                   .currentDummyElement(), 
          ele);

wdContext.nodeDummy().addElement(ele);

Note that copyCorresponding works only if the source & target nodes both have exactly similarly named attributes.

Regards,

Satyajit.

former_member192434
Active Contributor
0 Kudos

Hi

WdCopyService(Object source, Object target)

PS: both node attributes value should be same and data type as well.

Thanks

Former Member
0 Kudos

hi anup,

can u give an example, if i want to copy only the lead selected value of one node to another.

the code u suggested will copy all the elements right?

thnks in advance.

Edited by: jithin james on Dec 2, 2008 5:15 AM

former_member192434
Active Contributor
0 Kudos

Hi Jithin,

Suppose you have a context Node1(and it has some attributes) and you want to copy all the node attribute value to node2. just put the below method.

WDCopyService.copyElements(wdContext.node1, wdContext.node2);

Thanks

Anup

Former Member
0 Kudos

Hi,

refer the below threads,

refer this API also,

https://help.sap.com/javadocs/NW04S/current/wd/index.html

Regards,

ramesh