It works for me in firefox. Here is my piece of code

*client side code :*
FileUpload upload = new FileUpload();
Panel uploadPanel = new Panel();

        form.setAction(GWT.getModuleBaseURL() + "/myFormHandler");

form.setEncoding(com.google.gwt.user.client.ui.FormPanel.ENCODING_MULTIPART);
        form.setMethod(com.google.gwt.user.client.ui.FormPanel.METHOD_POST);
        VerticalPanel vertiPanel = new VerticalPanel();
        form.setWidget(vertiPanel);

        upload.setName("uploadFormElement");
        vertiPanel.add(upload);
        vertiPanel.add(uploadStatus);
        vertiPanel.add(new com.google.gwt.user.client.ui.Button("Submit",
new ClickHandler() {

            public void onClick(ClickEvent event) {
                if (upload.getFilename().length() == 0) {
                    MessageBox.setMinWidth(400);
                    MessageBox.alert("Can not Upload an Empty File");
                } else {
                    submissionStatus(upload.getFilename(),
currentProbNode.getId());
                    logEvent("SUB_" + currentProbNode.getId());
                }
            }
        }));
        form.addSubmitHandler(new
com.google.gwt.user.client.ui.FormPanel.SubmitHandler() {

            public void onSubmit(SubmitEvent event) {
                uploadStatus.setText("Status : Uploading.....");
                MessageBox.setMinWidth(300);
                MessageBox.wait("Please Wait While the File is being
Uploaded....");
//                MessageBox.alert(event.)
                uploadStatus.setVisible(true);
            }
        });
        form.addSubmitCompleteHandler(
                new
com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler() {

                    public void onSubmitComplete(SubmitCompleteEvent event)
{
                        uploadStatus.setText("");
                        uploadStatus.setVisible(false);
//                        MessageBox.alert("Completed");
                        MessageBox.alert("File Successfully Uploaded..!!!");
//                        MessageBox.alert("EVENT RESULTS
:"+event.getResults());
              //          window.hide();

                    }
                });
        uploadPanel.add(form);



*Servlet Code (call this method from doPost / doGet with request as an
argument):*

private FileItem getFileItem(final HttpServletRequest request) {
        FileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload(factory);
        try {
            List items = upload.parseRequest(request);
            //System.out.println("List Items, size --->" + items.size());
            Iterator it = items.iterator();
            while (it.hasNext()) {
                //System.err.println();
                FileItem item = (FileItem) it.next();
                //System.out.println("FILE NAME : " + item.getName());
                String extension="";
                if(item.getName().contains(".")){
                    int dotPos = item.getName().lastIndexOf(".");
                    extension = item.getName().substring(dotPos);
                    //System.out.println("EXTENSION : "+extension);
                }
                if (item.isFormField()) {
                    //System.out.println("File String->" +
item.getString());
                } else {
                    probNo = item.getFieldName();
                    System.out.println(String.format("File Name-> %s, Size->
%s, Content Type->%s, Isformfield-> %s, inMemory-> %s",
                            item.getFieldName(), item.getSize(),
item.getContentType(), item.isFormField(), item.isInMemory()));
                    this.processUpload(item,request,extension);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(e.toString());
            return null;
        }
        return null;
    }

This works fine for me in IE as well as Firefox. Hope it helps.



On Fri, Dec 4, 2009 at 12:52 AM, Lena <[email protected]> wrote:

> I'm writing a gwt site with a form using components from both gwt and
> gwt-ext. Since I need to send a file I can't use gwt's RPC services
> (GWTServletService), so I use a java servlet. I tried it in hosted
> mode and with IE6 and I recieve data properly. However, using firefox
> the servlet does not recieve anything.
>
> This is the gwt code corresponding to the form:
>
>            final FormPanel uploadForm = new FormPanel();
>            uploadForm.setAction(GWT.getModuleBaseURL() +
> "UploadFileServlet1");
>            uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
>            uploadForm.setMethod(FormPanel.METHOD_POST);
>            uploadForm.addFormHandler(new FormHandler(){
>                public void onSubmit(FormSubmitEvent event){
>
>                }
>
>                public void onSubmitComplete(FormSubmitCompleteEvent event){
>                        //getExistBD();
>                        //wait.hide();
>                        //MessageBox.alert(event.getResults());
>                }
>          });
>
>            // Create a FormPanel and point it at a service.
>            final com.gwtext.client.widgets.form.FormPanel inUploadForm =
> new
> com.gwtext.client.widgets.form.FormPanel();
>            inUploadForm.setPaddings(10);
>            inUploadForm.setLabelWidth(150);
>
>            FileUpload file = new FileUpload();
>            file.setName("file");
>            file.addStyleName("margin");
>
>            FieldSet fsBD = new FieldSet("Guardar en");
>            fsBD.addStyleName("fieldSet");
>
>            final Store statesStore = new SimpleStore(new String[]{"en",
> "es"}, getStates());
>            statesStore.load();
>
>            ComboBox cbSaveMode = new ComboBox("Tipo de base de datos",
> "saveMode", 200);
>            cbSaveMode.setEmptyText("Seleccionar...");
>            cbSaveMode.setStore(statesStore);
>            cbSaveMode.setDisplayField("es");
>            cbSaveMode.setValueField("en");
>            cbSaveMode.setReadOnly(true);
>            cbSaveMode.setForceSelection(true);
>            cbSaveMode.setMode(ComboBox.LOCAL);
>            cbSaveMode.setTriggerAction(ComboBox.ALL);
>            cbSaveMode.setBlankText("Este campo es obligatorio");
>            cbSaveMode.addListener(new ComboBoxListenerAdapter(){
>                public void onSelect(ComboBox comboBox, Record record, int
> index)
> {
>                        cbBD.setValue("");
>                        existBDStore.filter("en", comboBox.getValue());
>
>                        //if(comboBox.getValue().equals("public")){
>                        //      cbBD.setStore(existPublicBDStore);
>                        //}else if(comboBox.getValue().equals("private")){
>                        //      cbBD.setStore(existPrivateBDStore);
>                        //}
>                }
>            });
>
>            cbBD = new ComboBox("", "nameExistBD", 200);
>            cbBD.setEmptyText("Seleccionar...");
>            cbBD.setDisplayField("name");
>            cbBD.setValueField("id");
>            cbBD.setLinked(true);
>            cbBD.setMode(ComboBox.LOCAL);
>            cbBD.setTriggerAction(ComboBox.ALL);
>            cbBD.setReadOnly(true);
>            cbBD.setForceSelection(true);
>
>            final TextField nameField = new TextField("", "nameNewBD", 200);
>            nameField.disable();
>
>            final Radio rExist = new Radio("Base de datos existente", "bd");
>            rExist.setChecked(true);
>            rExist.setHideLabel(true);
>
>            final Radio rNew = new Radio("Nueva base de datos", "bd");
>            rNew.setChecked(false);
>            rNew.setHideLabel(true);
>
>            rExist.addListener(new CheckboxListenerAdapter(){
>                public void onCheck(Checkbox field, boolean checked){
>                        if(checked == true){
>                                cbBD.enable();
>                                nameField.disable();
>                        }
>                }
>            });
>
>            rNew.addListener(new CheckboxListenerAdapter(){
>                public void onCheck(Checkbox field, boolean checked){
>                        if(checked == true){
>                                cbBD.disable();
>                                nameField.enable();
>                        }
>                }
>            });
>
>            fsBD.add(cbSaveMode);
>            fsBD.add(rExist);
>            fsBD.add(cbBD);
>            fsBD.add(rNew);
>            fsBD.add(nameField);
>
>            Button uploadSubmitButton = new Button("Submit", new
> ButtonListenerAdapter(){
>                public void onClick(Button button, EventObject e) {
>                        uploadForm.submit();
>                }
>        });
>
>            inUploadForm.add(file);
>            inUploadForm.add(fsBD);
>            inUploadForm.add(uploadSubmitButton);
>
>            uploadForm.add(inUploadForm);
>
>            return uploadForm;
>
>
> And here's the java servlet code:
>
>           protected void doPost(HttpServletRequest request,
> HttpServletResponse response) throws ServletException, IOException {
>
>            FileItemFactory factory = new DiskFileItemFactory();
>            ServletFileUpload upload = new ServletFileUpload(factory);
>
>            try {
>                List items = upload.parseRequest(request);
>                Iterator it = items.iterator();
>
>                while (it.hasNext()) {
>                        FileItem item = (FileItem) it.next();
>                        if (!item.isFormField() &&
> "file".equals(item.getFieldName())){
>                                file = item.getInputStream();
>                        }else if("saveMode".equals(item.getFieldName())){
>                                saveMode =
> Streams.asString(item.getInputStream());
>                        }else if("nameExistBD".equals(item.getFieldName())){
>                                existBD =
> Streams.asString(item.getInputStream());
>                        }else if("nameNewBD".equals(item.getFieldName())){
>                                nameBD =
> Streams.asString(item.getInputStream());
>                        }
>                }
>            }catch(FileUploadException e){
>                e.printStackTrace();
>            }catch(IOException ioe){
>                ioe.printStackTrace();
>            }
>        }
>
>
> I've been trying to find out what happens for days and I don't
> understand what happens. If someone can help me I will ve very
> grateful.
>
> Thanks in advance
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "GWT-Ext Developer Forum" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<gwt-ext%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/gwt-ext?hl=en.
>
>
>


-- 
Thanks and Regards,
Deepak Kumar Mallapu,
IT Associate,
Center for Education Technology and Learning Sciences,
IIIT-Hyderabad,
Mobile :9866976686.

--

You received this message because you are subscribed to the Google Groups 
"GWT-Ext Developer Forum" 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/gwt-ext?hl=en.


Reply via email to