The next code is in the button action, the action is repetitive and my problem is that stored the value in this moment, the values previous are losing.
returns only one value.
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.io.Serializable;
import java.util.Random;
//int b = _documentIncrement;
Random rnd = new Random();
String codigo = rnd.nextInt().toString();
//String nombre = field_File1.getFileName();
HashMap<String,String> listaDocs = new HashMap<String,String>();
//instanciar clase
MiClase instancia = new MiClase();
//guardar en el hashmap
instancia.saveNameDocs(codigo,“nombre1”,listaDocs);
//mostrar hashmap
instancia.showList(listaDocs);
public class MiClase implements Serializable {
public static void saveNameDocs(String codigo, String nombre, HashMap <String,String> listaDocs){
listaDocs.put(codigo, nombre);
}
public static HashMap <String,String> showList(HashMap <String,String> listaDocs){
String clave;
Iterator<String> item = listaDocs.keySet().iterator();
while(item.hasNext()){
clave = item.next();
}
return listaDocs;
}
}