Store data in ArrayList variable

1
0
-1

I have a form1 with the components: 1. widget File. 1. widget Table. 2. summit buttons. I have the next process variables: loopingAdd of type Boolean listados of type ArrayList. nameDoc of type String.

On button 1: I have three actions: action 1: take the name of widgetFile and store in nameDoc.

String nombre = field_File1.getFileName();
return nombre

action 2: take the value of nameDoc and add to the listados variable

ArrayList<String> arr = new ArrayList<String>();
arr.add(nameDoc);
return arr;

action 3: loopingAdd = true. and addition I have GATEWAY1 if LoopingAdd == True, Loop back to the beginning of Step 1 and if LoopingAdd == False, then continue on to next step

I show the data in a table in this form:

List<List<Object>> listado=new ArrayList<List<Object>>();
for (Object nombre : listados){
List<Object> row=new ArrayList<Object>();
row.add(nombre);
listado.add(row);
}
return listado;

The problem is when you return to the same form, this shown in the table only the value name of the last uploaded document and so recursively. and I want to store in the "listados" variable all the documents names and then displayed in a table

Is there any solution or can not do it ?

Comments

Submitted by Sean McP on Wed, 05/20/2015 - 08:12

I'm only guessing at the moment but I'm going to take a step forward before answering this question.

So you have a table of file names, what do you want to do after this step? Do you want to upload the files, process them in anyway - like store them in a database or some other Document Management System?

If so then using your list like this will not work, you will need to use a DocumentList and rebuild it every time, see documentation here and here.

If you do want to use the files later in your process, for community the best way of doing it is in this post.

Back to your specific question:

If you really do only want the filenames in the table and do nothing with them later in the process (why I don't know) then I would do it this way:

*Note: I'm assuming you have a method of making loopingAdd=false; *

Step 1 - Script Connector - Initialize Empty listados of type ArrayList. Inclusive Gateway Step 2 - Human Task - Show the form (table has data = listados) Enter the data Click Submit Action 1: take the name of widgetFile and store in nameDoc. Operation 1: LHS listados "Takes Value Of" RHS Groovy Script

ArrayList<String> newrow = new ArrayList<String>();
newrow.add(nameDoc);

List<List<Object>> listado=new ArrayList<List<Object>>();
for (Object nombre : listados){
listado.add(nombre);  //nombre is already in the right format
}
listado.add(newrow);

return listado;

Gateway 2 is "If loopingAdd == true" then return to Inclusive Gateway else Continue

Hope that helps regards

PS code not tested...

Submitted by yannick.lombardi on Wed, 05/20/2015 - 10:06

Hi.

action 2: take the value of nameDoc and add to the listados variable

Instead of "takes value of", did you try to choose the java method "add". If you do this, you can directly add 'nameDoc' to your list without overwriting the list.

Another solution is to change the script like this :

    ArrayList<String> arr = listados;
    arr.add(nameDoc);
    return arr;
Submitted by stalinramirez on Thu, 05/28/2015 - 21:46

Hi, Sean , Yannick Thank you for answering my questions. I was trying to make a multi file upload module but it is impossible with Programming in Bonita Studio. But I read a lot in the forum and see that the only way to do that is using REST API using JAVA and MAVEN. The most of my project is done and I only need that little module. and already I want to graduate and this problem can not regards.

Submitted by Sean McP on Fri, 05/29/2015 - 04:44

Hi Stalin,

Impossible? No not at all, using my post as previous works and works very well, others have used it to success.

You say you want to do multi-file upload in community. Ok. This is what the previous post does. Can you describe the process exactly, what you want to do, step 1, step 2, step 3 etc.

Thanks

Submitted by stalinramirez on Sat, 05/30/2015 - 01:19

Sean. The process is large but in step that must upload the files, the secretaries upload "x" files, there is also another step in a commission which reviewed uploads files one by one. note: could package them into a zip but secretaries do not want to do and my tutor requires me to do a module multi file upload I hope I've explained

No answers yet.
Notifications