Re: How to upload a file using GWT ?
Hi, I've finally figured it out. In order to link the form with the servlet, you have to map the servlet in web.xml. It is similar to writnig the struts-config.xml file. After putting the servlet info there, you just need to pass the servlet url in the form action, and on submit you will end up with the execution of the servlet. On Feb 10, 6:20 pm, ender alin.p.voi...@gmail.com wrote: 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 Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~--~~~~--~~--~--~---
How to upload a file using GWT ?
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 Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~--~~~~--~~--~--~---
Re: How to upload a file using GWT ?
So I think you can refer to this message... Err, i'm not English people, so i don't know how to name it...is it message? or address ? or what..? http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/420eaa5f81590862# This is send by me, and i just have the similar problem as you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~--~~~~--~~--~--~---