5 Replies Latest reply on Jun 16, 2009 10:13 AM by Aurel Avramescu

    S:fileUpload problem with a4j Commandbutton

    tarun bansal Newbie

      Hi


      I am using s:fileupload control with ajax commandbutton(a4j:commanButton), but it is does not work. When I replace the a4j:commanButton with h:commandButton then it works fine.



      Please suggest me something about the difference.


      Best Reagrds
      Tarun Bansal

        • 1. Re: S:fileUpload problem with a4j Commandbutton
          John Ament Master

          I think you'll have to clarify what you mean by It doesn't work.  if you could also post how you implemented it, it may help figure out why.  Personally, I prefer richfaces' fileupload control, but that's just me.

          • 2. Re: S:fileUpload problem with a4j Commandbutton
            tarun bansal Newbie
            I am using a simple backing bean and a byte array


            `
            the portion of code in seam component

                     private byte[] data;

                 
                 public byte[] getData() {
                      return data;
                 }

                 public void setData(byte[] data) {
                      this.data = data;
                 }

                 public void action() {
                      System.out.println(this.getData().length);
                 }


            code in Xhtml page:

            <h:form id="fileEditForm" enctype="multipart/form-data">

            <s:fileUpload data="#{excelUploadBean.fileData}" />

            <h:commandButton value="Submit"  id="submitExcel" action="{excelUploadBean.action}" >

            </h:form>






            when I replace the  `<h:commandButton value="Submit"  id="submitExcel" action="{excelUploadBean.action}" >` with `<a4j:commandButton value="Submit"  id="submitExcel" action="{excelUploadBean.action}" >`

            the "byte[] data"(in action method) remains null.
            • 3. Re: S:fileUpload problem with a4j Commandbutton
              tarun bansal Newbie
              <blockquote>
              _tarun bansal wrote on Feb 17, 2009 05:53:_<br/>

              I am using a simple backing bean and a byte array


              `
              the portion of code in seam component

                       private byte[] data;

                     
                      public byte[] getData() {
                              return data;
                      }

                      public void setData(byte[] data) {
                              this.data = data;
                      }

                      public void action() {
                              System.out.println(this.getData().length);
                      }


              code in Xhtml page:

              <h:form id="fileEditForm" enctype="multipart/form-data">

              <s:fileUpload data="#{excelUploadBean.data}" />

              <h:commandButton value="Submit"  id="submitExcel" action="{excelUploadBean.action}" >

              </h:form>






              when I replace the  `<h:commandButton value="Submit"  id="submitExcel" action="{excelUploadBean.action}" >` with `<a4j:commandButton value="Submit"  id="submitExcel" action="{excelUploadBean.action}" >`

              the "byte[] data"(in action method) remains null.
              </blockquote>

              sorry the tag in xhtml for fileupload is <s:fileUpload data="#{excelUploadBean.data}" />
              • 4. Re: S:fileUpload problem with a4j Commandbutton
                sha thomas Newbie

                I am having a similar problem. It works fine with h:commandLink, but when I use a4j:commandLink, the file upload control values ( filename and data ) are coming in as null values in the action bean.


                Did you get it working? Would you please share the solution/workaround?

                • 5. Re: S:fileUpload problem with a4j Commandbutton
                  Aurel Avramescu Newbie

                  I had the same problem also with files uploads, also for file downloads. Because for both cases I needed the a4j commandButton or commandLink to use f:setPropertyActionListener I've made the next trick: when I click a4j commandButton or a4j commandLink I am opening a modalPanel frame, and I am using s:link or s:button, depends what I need.