cancel
Showing results for 
Search instead for 
Did you mean: 

more than one value

Former Member
0 Kudos

Hi!

How can I store or save in context node value

more than one data. For example the content

of an Array or Container etc...

regards

sas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi sas,

Suppose you have an array countries[]={"UK","Italy","Germany"} and you want to store it in a node 'Country' with a value attribute 'name'. Suppose the node is created in your view's context and view name is 'TestView' . This is how you do it.




 IPrivateTestView.ICountryElement element=null;

for(int i=0;i<countries.length();i++){

element=wdContext.nodeCountry().createCountryElement();
element.setName(countries<i>);
wdContext.nodeCountry().addElement(element);

}

Regards,

Shabeer.

Answers (5)

Answers (5)

Former Member
0 Kudos
How can I store or save in context node value
more than one data. For example the content
of an Array or Container etc...

String Result ="";
String Array[] = {"a","b","c","d","e"};
for(int i=0;i<Array.length();i++)
{
  Result += Array<i>+",";
}
wdContext.currentNode().setValue(Result);

Use StringTokenizer while retriving,

String Final = wdContext.currentNode().getValue();
StringTokenizer Tokenizer = new StringTokenizer(Final,",");
int i=0;
while(Tokenizer.hasMoreElements())
{
  Array<i> = Tokenizer.nextToken();
  i++;
}

Former Member
0 Kudos

hai erdam sas

try this code ,it easy n it works

create a context node and an attribute under that node use ur node and attribute in this code.bine that node to the drop down by index UI element in Layout.

try

{

IPrivateKv_bus.IKvnodeNode kvlevel=wdContext.nodeKvnode();

List lis=new ArrayList();

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

{

if(i==0)

{

IPrivateKv_bus.IKvnodeElement el11 = kvlevel.createKvnodeElement();

el11.setKvlevel("Select kvlevel");

lis.add(el11);

}

if(i!=0)

{

IPrivateKv_bus.IKvnodeElement el11 = kvlevel.createKvnodeElement();

el11.setKvlevel("kvlevel"+i);

lis.add(el11);

}

}

kvlevel.bind(lis);

}

catch(Exception e)

{

}

place this coding in init method of your view.any issues plz let me know.

Thanks n Regards

Sharanya.R

Edited by: Sharanya.R on Mar 25, 2008 1:08 PM

Former Member
0 Kudos

Hi!

Cay you please tell me the difference between

bind and create. We have here both versions

at the below shown example.

Regards

sas

IPrivate<View Name>.IProductsElement product = wdContext.createProductsElement();

product.setName("Product 1");// Name attr under node Products

product.setPrice("89,90"); // Price attr under node Products

product.setProductId("P1");// ProductId attr under node Products

product.setQuantity(850); // Quantity attr under node Products

product.setDetails("Detailed description of product PP-1020");

products.add(product);

product = wdContext.createProductsElement();

product.setName("Product 2");

product.setPrice("849,00");

product.setProductId("P2");

product.setQuantity(12);

product.setDetails("Detailed description of product 2");

products.add(product);

wdContext.nodeProducts().bind(products);

Former Member
0 Kudos

Hi,

wdContext.createProductsElement();

Above statement creates a new element for products node, but the element is <b>not</b> bound to the node.

To make this element part of the node you can use either of the following

Use bind(IProductsElement)} or

IWDNode bind(Collection)} to bind it, here you can bind mulitiple elements.

or IWDNode addElement(IWDNodeElement)

to add it to the node.

Alternatively yuo can use createAndAndOrdersElement()

So they all do the same.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi Raj,

im having the same scenario as this....

I'm having some 10 dropdowns.

The selected names in these dropdowns i'm saving back in R/3.

In the view i'm having a node vn_selectedmembers and a attribute va_fullname and va_usergroup.

Now i need to save all the selected names in the same attribute vafullname and their corresponding usergroup in va_usergroup_.

right now i'm having seperate action for every dropdown and setting the selected names and its user group to the attribute va_fullname and va_usergroup respectively in the on action method of each dropdown.

but its taking only the last selected value, that is the attribute has only one name.

how to solve this? please explain me with detailed procedure

Regards,

Suresh

Former Member
0 Kudos

Hi,

Suppose you have details of products in a list.

Then you can put these data into node using:

List products = new ArrayList();

wdContext.nodeProducts().bind(products);

// where Products is your node.

Or if you have lot other info for product, then:


	IPrivate<View Name>.IProductsElement product = wdContext.createProductsElement();
	
	product.setName("Product 1");// Name attr under node Products
	product.setPrice("89,90"); // Price attr under node Products
	product.setProductId("P1");// ProductId attr under node Products
	product.setQuantity(850); // Quantity attr under node Products
	product.setDetails("Detailed description of product PP-1020");
	products.add(product);
	product = wdContext.createProductsElement();
	product.setName("Product 2");
	product.setPrice("849,00");
	product.setProductId("P2");
	product.setQuantity(12);
	product.setDetails("Detailed description of product 2");
	products.add(product);

                wdContext.nodeProducts().bind(products);

Hope this will help you.

thanks & regards,

Manoj

sridhar_k2
Active Contributor
0 Kudos

Sas,

Better way to store in java.util objects. Create context variable whose type is List or ArrayList or HashMap.

Set and get in the regular way to / from the context.

Regards,

Sridhar