Hy guys,
I find myself in a middle of a problem, because I don't know how can I
upload a file using the GWT.
I will give you an example of what I am doing. Please help me figure
this out....
//... code
FileUpload fileUpload = new FileUpload();
fileUpload.setName("file");
fileUpload.setTitle("File");
fileUpload.setVisible(true);
fileUpload.setSize("330" , "auto");
//this is added in the FormPanel later
formPanel = new FormPanel(); // the formPanel contains an UploadFile
which
formPanel.setEncoding("multipart/form-data");
formPanel.setMethod(FormPanel.METHOD_POST);
downloadButton.addListener(Events.Select, new Listener() {
public void handleEvent(BaseEvent be) {
submitForm();
//validForSubmit = true;
}
});
private void submitForm() {
ImpexDefinitionMgrAsync impMgr = ImpexDefinitionMgrAsync)
SafirWebUI.getServiceForEntity(ImpexDefinition.class.getName());
impMgr.importFile(fileUpload.getFilename(),
this.parentGridPanel.getClassName(), new MaskAsyncCallback() {
@Override
public void onSuccessInternal(Object result) {
//Long id = ((ImpexDefinition) result).getId();
//importDetailId.setValue(id != null ?
id.toString() : null );
formPanel.setAction(ServiceLocator.server_URL +
"reports/upload");
formPanel.submit();
}
});
}
//.... end of code
This way I can only transfer to the server side the file path but this
is wrong because the only place where it shall work is on the
localhost, otherwise on another server, it will crash, because the
file will not be found. I thought either I read the file and send its
content, or I send the whole file (and this is the best approach but I
don't know how to do it, since GWT doesn't know java.io).
Hope you will have an idea...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---