[FileUpload]Lecture d'un fichier sur le poste client
Bonjour, :)
J'ai besoin de récupérer un fichier CSV sur le poste client pour ensuite le parcourir du coté serveur. Je me suis donc naturellement tourné vers la classe FileUpload :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
// Create a FormPanel and point it at a service.
final FormPanel form = new FormPanel();
String urlAction = "/nom_du_projet/nom_du_projet.action";
form.setAction(urlAction);
initWidget(form);
// Because we're going to add a FileUpload widget, we'll need to set the
// form to use the POST method, and multipart MIME encoding.
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
// Create a panel to hold all of the form widgets.
VerticalPanel panel = new VerticalPanel();
form.setWidget(panel);
// Create a FileUpload widget.
upload = new FileUpload();
upload.setName("uploadFormElement");
panel.add(upload);
// Add a 'submit' button.
panel.add(new Button("Submit", new ClickListener() {
public void onClick(Widget sender) {
form.submit();
}
}));
// Add an event handler to the form.
form.addFormHandler(new FormHandler() {
public void onSubmit(FormSubmitEvent event) {
}
public void onSubmitComplete(FormSubmitCompleteEvent event) {
Window.alert(event.getResults());
}
});
} |
Le problème c'est que "event.getResults()" me renvoie tout le temps
Code:
<DIV id=slot></DIV>
sans rien dedans. :cry:
Et si je change l'urlAction cela me renvoie un truc du genre "etat http 404 - la ressource n'est pas disponible". Ce qui me fait dire que l'url est bonne. Me manque-t-il quelque chose d'autre? ou un paramètrage ? J'ai pourtant vu plusieurs tutoriels GWT qui font exactement comme moi!
Merci d'avance!;)