cancel
Showing results for 
Search instead for 
Did you mean: 

How to store data from multiple Array into the context.

Former Member
0 Kudos

We had created a web service which accepts an array of array of variable length.So I would like to know how can i store that array into the context so that at the end i can send it to the webservice.

Is there any way by which we can create variable context element to store data..

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks for u r response.Wat i had done is i had mapped the input field to the context element, and on the click of add i m creating an object and populating it into an array list and finally depending upon the arraylist i m creating an array object with i m sending to my web services.I tried oing this methods as u guys have said ,but it's not working in my case becoz the structure is too complex full of arrar with arrays and so.

Former Member
0 Kudos

Amit,

Please post your code.

Former Member
0 Kudos

My Web service accepts an array.So how can i map my fields on my screen to the context which should have been an array,so that i could directly send that array in the context to the web service.

So could any body tell me how can i make an array int the context wand how to make the input fields to the array.

Former Member
0 Kudos

Hi,

I'm not able to fully understand your requirement. However from what I have understood my I explain.

You can enter values from the inputField to an attribute in the context and on the click of a button you may store it to the context node/ array(to input into the web service) which could hold various values.

If you have stored it in the context node you can set the values explicitly into an array and send it to the model(programmatically).

If you need to store the value from the array into context, you can do the reverse i.e once the array is populated just fill in the context with the values(programmatically).

Please let me know if you require further clarification.

Regards

Noufal

Former Member
0 Kudos

What my requirement is, i want ot send an array to my webservices and for that i want to represent an aray in the context so that when i click add button on the screen the whole group which has various input fields should go into the array of the context.and it should continue until i click add button and at the end i will sent that array in the context to the web services( what is required by my web service).

So could any body tell me how to represent an array in the context and how to increment it on add click event.so that the array is maintained in teh context.

Former Member
0 Kudos

Hi,

When you have a pre-defined number of input fields.. from where you enter the values... u can create as many attributes in the node.. and create elements as you add for each set of input !

Where does an array of array(variable length ) fit into.. can you elobarate on the actual scenario in the applciation rather than explaining us what u want in the program.. Maybe people can find u a different way out.!

Regards

Bharathwaj

former_member185029
Active Contributor
0 Kudos

Hi,

As Bharathwaj said, you can create as many value attributes in a node.

Also incase you have array of array (an array of collection objects in suppose) You can have node inside node. So the top node represents your main array and inside node with single value attribute represents your inner array elements (Collection objects).

See the structure below.

OuterNode

   |_

InnerNode

  |_

Collection Value Attributes

Hope that will help you.

Ashutosh

Former Member
0 Kudos

Suppose that you want to send array <i>string data[]</i> to your web service.

Define a value node <i>MyNode</i> with one value attribute <i>data</i> with datatype string. Ensure the cardinality of the <i>MyNode</i> is 0..n.

Whenever you need to add element to an array create element in <i>MyNode</i>, set the data and add it to node <i>MyNode</i>.

Call this <i>addData(String)</i> from event handler button click or whereever u want to add.


void addData(String value) {

IWDNodeElement element = wdContext.nodeMyNode.createElement();
element.setAttributeValue("data", value);
wdContext.nodeMyNode.addElement(element);

}

When you need to pass the array, loop through the node <i>MyNode</i> and compile the array.

for(int i = 0; i< wdContext.nodeMyNode.size(); i++) {

 //   ... = wdContext.nodeMyNode.getElementAt(i);

}

If u want to pass two dimentinal array, create another node in <i>MyNode</i>.

Former Member
0 Kudos

You can create context attributes of any Java type. Only if you intend to bind UI element properties to a context attribute, it must have a DDIC type.

Armin