3 Replies Latest reply on May 9, 2008 1:50 PM by titou09

    Bug ? s:fileUpload with h:dataTable

    michalf

      Hello,
      I have problem with uploading files.
      When I try:



          <h:form enctype="multipart/form-data">
      
                   
      
                    <c:forEach items="#{dictionaryTest.tempBuffer}" var="b">
      
                              <s:fileUpload contentType="#{b.contentType}" fileName="#{b.filename}" data="#{b.content}">
      
                              </s:fileUpload>
      
                    </c:forEach>
      
      
                    <h:commandButton action="#{dictionaryTest.upload}" value="Upload"></h:commandButton>
      
          </h:form>   



      Everything is OK. File names and file content in array are different. But when I change to:


          <h:form enctype="multipart/form-data">
      
      
                    <h:dataTable value="#{dictionaryTest.tempBuffer}" var="b">
      
                         <h:column>
      
                              <s:fileUpload contentType="#{b.contentType}" fileName="#{b.filename}" data="#{b.content}">
      
                              </s:fileUpload>
      
                         </h:column>
      
                    </h:dataTable>
      
                    
      
      
                    <h:commandButton action="#{dictionaryTest.upload}" value="Upload"></h:commandButton>
      
          </h:form>


               
      File names in array are the same,

      tempBuffer[0].filename == tempBuffer[1].filename == tempBuffer[0].filename

      and file content is not empty only in
      tempBuffer[0]

      .
      The same situation is with using rich:dataTable / rich:column.
      Is it a bug ? Why s:fileUpload does not work with h:dataTable ?


      
      @Name("dictionaryTest")
      
      @Stateful
      
      @Scope(ScopeType.SESSION)
      
      public class DictionaryTest implements IDictionaryTest
      
      {     
      
             File[] tempBuffer = new File[] {new File(), new File(), new File() } ;
      
             
      
      
      
                public File[] getTempBuffer() {
      
                     return tempBuffer;
      
                }
      
      
                public void setTempBuffer(File[] tempBuffer) {
      
                     this.tempBuffer = tempBuffer;
      
                }
      
      }
      
      



      
      @Entity
      
      @Table(name = "FILES")
      
      public class File implements Serializable
      
      {
      
          private Long id;
      
          private byte[] content;
      
          private String contentType;
      
          private String filename;
      
      
          // setters ang getters
      
      }