How to change a value in a dataslot of type list

Posted by jbr on 26-Jul-2011 06:24

Hi there,

I've got a dataslot of type list with size 5 and I want to change the 2 entry. Can I use Javascript 'putDataslot' to achieve this or is there another way.

TIA,

John Brink

All Replies

Posted by ramkumar7800 on 26-Jul-2011 07:15

Hi John,

As per my understanding you want to reduce the list dataslot values from 5 to 2. If you are doing it in pre/post scripts of worksteps then jst.putDataSlot is fine but on form you have to use bean.setPropString().

Besides this you have to do some java coding for this.

Posted by jbr on 26-Jul-2011 07:23

Hi,

No, that's not exactly what I want; suppose I've got a DataSlot of type List with the following values ["first element", "second element", "third element", "fouth element", "fifth element"] and now I want at the end of the WS change "second element" into "new second value". The number of elements stays the same and the values of the other elements too. I thought something like putDataslot("mylist[1]", "new second value") but that doesn't work.

Regards,

John

Posted by ramkumar7800 on 27-Jul-2011 06:56

Hi JOhn,

Please try the following code in post script of that workstep -

java.util.ArrayList lst=jst.getDataSlot("Name of dataslot");

for(int i=0;i

{

   lst(i)="New value";

}

jst.putDataSlot("Name of dataslot",lst);

Regards,

Ram Sharma

Posted by jbr on 27-Jul-2011 08:31

Hi Ram Sharma,

That didn't solve my problem; however Venkat came with the following solution:

var ls = new java.util.Vector();
ls.add("Apple");
ls.add("Mango");
ls.add("Grape");
jst.putDataSlot("list_ds", ls);
With this I can solve my problem.

Thanks for your help.
Regards,
John
This thread is closed