cancel
Showing results for 
Search instead for 
Did you mean: 

Bind node to Collection

Former Member
0 Kudos

i have a method which return a collection


Command Bean
public getResult(){
Collection newcol=new ArrayList();
bean.setxxx(xxx);
bean.setxxx(xxx);
bean2.setxxx(xxxx);
bean2.setxxx(xxxx);
newcol.add(bean);
newcol.add(bean2);

return newcol;
}

webdynpro
public void init(){
col=getResult();
wdContext.nodeEmailOutCommandBean().bind(col);    //bind to bean 
wdContext.nodeEmailOutDetailsCommandBean().bind(col);  //bind to bean2
}

how can i do this...

Message was edited by:

yzme yzme

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

maybe my question is not clear

i bind to a model bean..


i have a method which return a collection

Command Bean
public getResult(){
Collection newcol=new ArrayList();
bean.setxxx(xxx);
bean.setxxx(xxx);
bean2.setxxx(xxxx);
bean2.setxxx(xxxx);
newcol.add(bean);
newcol.add(bean2);
 
return newcol;
}
 
webdynpro
public void init(){
col=getResult();
wdContext.nodeEmailOutCommandBean().bind(col);    //bind to bean 
wdContext.nodeEmailOutDetailsCommandBean().bind(col);  //bind to bean2
}


what i want is if i bind to nodeEmailOutCommandBean I WANT TO GET BEAN

if i bind to nodeEmailOutCommandBean I WANT TO GET BEAN2

in array i can use...

ArrayList arr=new ArrayList;

if (arr.get(0) instanceof Bean){

........

}else if(arr.get(0).instanceof Bean2){

.....

}

Former Member
0 Kudos

Hi ,

I am not sure if i have understood your requirement. If u want different collections to be passed to different bean read the collection object..

use collection.toArray or use a iterator and get the bean objects.. and add them appropriately.

Regars

Bharathwaj.

former_member182372
Active Contributor
0 Kudos

Hi,

wdContext.currentEmailOutCommandBeanElement().modelObject() should return bean.

wdContext.currentEmailOutDetailsCommandBean Element().modelObject() should return bean2.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim,

Isnt it that, it will be available in the node only after he binds them

Former Member
0 Kudos

can u please tell me steps clearly for gettting the collection from the bean class

my code is like this

public class SimpleData

{

private String name=null;

private String number=null;

Collection c=new ArrayList();

public Collection getCollectionData()

{

SimpleView sv1=new SimpleView();

sv1.setName("abc");

sv1.setNumber("xtz");

c.add(sv1);

SimpleView sv2=new SimpleView();

sv2.setName("aaaaaaaaa");

sv2.setNumber("bbbbbbbbb");

c.add(sv2);

return c;

}

public void setName(String name)

{

this.name=name;

}

public void setNumber(String number)

{

this.number=number;

}

public String getName()

{

return name;

}

public String getNumber()

{

return number;

}

}

i know how to create a model

but i am not getting how to create relationship for list methods

after how to bind can u please tell me quickly

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi,

Create a Value Node of cardinality 0..n

under which create a value attribute and change the type to your Bean Class.

You can use your code now...

Regards

Abhimanyu L

Former Member
0 Kudos

<i>Create a Value Node of cardinality 0..n</i>

Wrong. It's necessary to create a model node. But first it's necessary to import JavaBean model. Then add this model to component and only afterwards create Model Node with model class that correspond to JavaBean.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Valery,

can't we assign bean instance to a value attribute?

always do we have to use the import bean model?

can you please explain the advantages in this case?

Thanks & Regards

Abhimanyu

Former Member
0 Kudos

Abhimanyu,

In original question author tries to bind collection of model objects to node. This is only possible for model node. To use model node it's mandatory to have model -- like Adaptive RFC Model, or WS model, or JavaBean model in this case. So model import is mandatory here.

Sure, it's possible to use value node and copy attribute values back and force many times. This leads to data synchronization problems (between node elements and model objects), this provokes writting repetative code and so on. In general, I would highly recommend using model nodes when you need to "bind" UI to your model objects.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Thanks Valery,

totally convinced.

Regards

Abhimanyu L