Upload component how to control if is empty

Hi guys!
I’m having a little problem that I hope we can fix.
The thing is… I have a form that the user can input new data to save in database, so the user can input two textfields and a dynamic number of files. But I can’t control that and I don’t know how I can solve it. The problem comes because I don’t have a tipically button of Upload component that upload the file to server, I want to upload all files only with one button, so… the user can decide if want or not want files to upload, currently I’m trying to control that with a listener that is seeing if the upload is finished but is not working as I wish. I let here some of the code.

[code]
if(!textField_1.getValue().toString().isEmpty() && !richTextArea_2.getValue().toString().isEmpty()) {
template = new Templates();
template.setContext(c);
template.setSubject(textField_1.getValue().toString());
template.setBody(richTextArea_2.getValue().toString());

                System.out.println("XAVI MAP::::::::::: " + listUploads.size());
                for(int i=1;i<=listUploads.size();i++) {
                    final int flag = i;        
                    System.out.println("XAVI::::::::::: " + i);
                    listUploads.get(i).submitUpload();                                            
                    listUploads.get(i).addListener(new Upload.FinishedListener() {
                                                    
                            public void uploadFinished(FinishedEvent event) {
                                if(listUploads.size() == flag){                                    
                                    //bandera = false;
                                    System.out.println("XAVI::::::::::: " + flag);
                                    accordion_respostes.addTab(new PlantillaView(mainWindow, panel_1, c, template, accordion_respostes, response), template.getSubject());                        
                                    templateBusinessManager.saveTemplate(template);
                                    mainWindow.removeWindow(getWindow());
                                }
                            }
                    });                                
                    accordion_respostes.addTab(new PlantillaView(mainWindow, panel_1, c, template, accordion_respostes, response), template.getSubject());                        
                    templateBusinessManager.saveTemplate(template);
                    mainWindow.removeWindow(getWindow());                                            
                }                    
                
            }

[/code]Thanks for advice!
Greetings