cancel
Showing results for 
Search instead for 
Did you mean: 

add values into view controller 's attribut

Former Member
0 Kudos

Dear All!

I would like store some data in the view controller.

It is a value attribut and has the type java.util.List.

1. How can I add now many values into this attribut

2. How can I get this values again ?

Regards

sas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

use as follows


 //Lets say liststore is you context attribute of type list
	  List list = wdContext.currentContextElement().getListStore();
	  list.add(<object>); // add your objects to the list
	  //store the list back to the context
	  wdContext.currentContextElement().setListStore(list);

Regards

Ayyapparaj

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

but I have many Objects.

In this case I can populate list only with one object?

What happens of having more object (e.g. 200)

list.add(<object>); // add your objects to the list

regards

sas

Former Member
0 Kudos

Hi,

You can add as much as you wish and your system supports

Ex: to add 10 contents


List list = wdContext.currentContextElement().getListStore();

for(int x=0; x<10; x++)
	  list.add(<object>); 

Regards

Ayyapparaj

former_member197348
Active Contributor
0 Kudos

Hi Sas,

You can add like this:

for(int i=0;i<wdContext.node<node>().size().;i++)

{
IPrivate<viewname>.I<node>Element ele = wdContext.node<node>().get<node>().ElementAt(i);
list.add((Object)ele);
}

regards,

Siva

former_member197348
Active Contributor
0 Kudos

Hi Sas,

The list is similar to any value node.

You can add elements like this.

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

{

IPrivate<viewname>.I<node>Element ele = wdContext.create<node>Element();

ele.set<attribute>(" "+i);

wdContext.node<node>().addElement(ele);

}

You can get elements like this:

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

{

IPrivate<viewname>.I<node>Element ele = wdContext.node<node>().get<node>().ElementAt(i);

ele.get<attribute>();

wdContext.node<node>().addElement(ele);

}

regards,

Siva

Former Member
0 Kudos

Hi,

you can have a value Node ex. "MyList".Now add value attribute say "MyName" of type String under the value node.set the cardinality of the node MyList to 0:n.

Now you can add the elements by

IMyListElement ele=wdContext.nodeMyList().createMyListElement();

ele.setMyName="name";

wdContext.nodeMyList().addElement(ele);

Repeat the above lines to add more elements.

Regards,

Sudhir