4 Replies Latest reply: Dec 10, 2012 2:56 PM by polo RSS

    File upload

    polo
      Hi,

      I am trying to upload a file and I am getting IE's warning message "Webpage needs to resend the information, you have previously submitted". Any idea how can i workaround this?

      This is my current situation:
      Using Jdev11.1.1.4

      I have Main JSPx page and inside a page I have region which is show a bounded taskflow.
      I am trying to upload a file from one of the page fragment of the task flow.

      I have setup the useforupload property on main jspx page to true.

      Please suggest me some ways to resolve this IE's warning message: "Webpage needs to resend the information, you have previously submitted".

      THank you

      -R
        • 1. Re: File upload
          Timo Hahn
          Can you post the code you use on the fragment and in the bean?
          Have you tested this using an other browser?


          Timo
          • 2. Re: File upload
            polo
            Timo,

            Thank you for your response. I just tried in firefox and fileupload works. but fails on IE...

            Following is my code for pagefragment:

            <af:panelGroupLayout id="pgl2" layout="horizontal">
            <af:inputFile label="Select file to upload:" id="if1"
            valueChangeListener="#{viewScope.FileUpload.valueChangeFile}" autoSubmit="true"
            binding="#{viewScope.FileUpload.filebinding}"/>
            </af:panelGroupLayout>

            Following is my code for bean
            UploadedFile myfile = (UploadedFile)valueChangeEvent.getNewValue();
            FacesContext fctx = FacesContext.getCurrentInstance();
            ServletContext servletCtx = (ServletContext)fctx.getExternalContext().getContext();
            String imageDirPath = servletCtx.getRealPath("/");
            BufferedInputStream bin = null;
            FileOutputStream fout = null;
            BufferedOutputStream bout = null;
            InputStream inputStream = null;
            File outputFile = null;

            try {
            inputStream = myfile.getInputStream();
            String fileName = myfile.getFilename();
            String filePath = "c:/images/" +fileName;

            DCIteratorBinding fileit = ADFUtil.getBindingIterator("TView3Iterator");
            ViewObject vo = fileit.getViewObject();

            Row row = vo.createRow();
            row.setNewRowState(Row.STATUS_INITIALIZED);
            vo.insertRow(row);
            row.setAttribute("Filepath", filePath);
            row.setAttribute("Contenttype", myfile.getContentType());
            row.setNewRowState(Row.STATUS_NEW);

            outputFile = new File("c:/images/" + fileName);
            bin = new BufferedInputStream(inputStream);
            fout = new FileOutputStream(outputFile);
            bout = new BufferedOutputStream(fout);
            int i;
            while ((i = bin.read()) != -1) {
            bout.write(i);
            }

            } catch (Exception ex) {
            ex.printStackTrace();
            // handle exception
            } finally {
            try {
            inputStream.close();
            } catch (IOException ioe) {
            // TODO: Add catch code
            ioe.printStackTrace();
            }
            try {
            bin.close();
            } catch (IOException ioe) {
            // TODO: Add catch code
            ioe.printStackTrace();
            }
            try {
            bout.close();
            } catch (IOException ioe) {
            // TODO: Add catch code
            ioe.printStackTrace();
            }
            try {
            fout.close();
            } catch (IOException ioe) {
            // TODO: Add catch code
            ioe.printStackTrace();
            }
            outputFile = null;

            }
            }

            Edited by: polo on Dec 7, 2012 11:34 AM
            • 3. Re: File upload
              Timo Hahn
              polp, beside that you don't dispose the UploadedFile used resources I don't see anything which rings a bell.
              Have you tested to do exactly this on a normal page, not from inside a fragment?

              Timo
              • 4. Re: File upload
                polo
                Yes Timo I tried this on stand alone page and it works fine......

                The only problem is when i try to use this in page fragments (bounded task flow)....

                Given this current situation.... if this doesn't work then I have to let user go out to seperate file upload page.... to upload a file.....it sucks... but i can't really have much to play around....

                do you thing of any other work around to let user stay on the same task flow and open new page to upload a file?

                Thank you,

                -R