2 Replies Latest reply on Oct 3, 2007 1:17 AM by gothmog

    s:fileUpload and Ajax4jsf

    carloszaniolo

      Hi guys,

      It's a very good news that Jboss seam and Ajax4jsf will work together!!!
      BTW seam file upload is not working with Ajax. I think it is because of the A4J submit behaviour.

      my code:

      <a4j:form id="formUpload" enctype="multipart/form-data" >
       <s:fileUpload id="document" data="#{controller.file}" accept="images/*" />
       <a4j:commandButton id="upload" value="Upload..." action="#{controller.upload}" />
      </a4j:form>


      If I change a4j:commandButton for h:commandButton it works, but is not ajax. I've tried a4j:form with ajaxSubmit=true also...

      Is there anything I can do?

      tkx!

        • 1. Re: s:fileUpload and Ajax4jsf

          BTW: Did you even hear about fileUpload working with Ajax?

          http://www.captain.at/ajax-file-upload.php

          The implementations that I saw use two different channel. iframe for upload, and a regular ajax call for checking the status (showing the progress bar)

          • 2. Re: s:fileUpload and Ajax4jsf

            did anyone get a solution to this other than the php one described in the link above?

            For example it must be possible as gmail do it with attachments and I'm pretty sure that it is using some asynchronous technique.

            If you think about the following, its actually really useful to have an ajax file upload ability:

            Scenario:
            User has a two field form, name (required) and image and would like to see the image before doing the final submit of form. The name is a simple input text and the image is an input file.

            The proposed solution is to upload an image, return to the page with the displayed image in one step and then submit the form in another step.

            Problem is that on the submit of the fileupload, jsf validation kicks in and stops the upload if the user hasn't entered a name value. (i.e. because an entire form submit was done to try and get the image uploaded)

            How do you get around this?

            You need to submit the image either
            1) with an immediate ajax4Jsf request or
            2) a normal submit which bypasses the JSF validation phase

            Does anyone know how to do either or both ?

            Troy