1 2 Previous Next 22 Replies Latest reply on Nov 19, 2012 3:08 PM by alpamys.kanibetov

    s:fileUpload

    lasansue.jeremy.girard.satives.fr

      Hi all,


      I tried to upload a file using s:uploadFile. I follow the reference manual but it still not work. All attributes are empty.


      Added in components.xml


      <web:multipart-filter create-temp-files="false" 
                                max-request-size="5200000" 
                                url-pattern="/*"/>




      No add in web.xml seam filter was already set.


      my xhtml page :


      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                                   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:s="http://jboss.com/products/seam/taglib"
                      template="#{theme.template}">
      
      <ui:define name="content">
         <div class="imageEntry">
            <h:form enctype="multipart/form-data">
            
               <h:messages globalOnly="true" styleClass="errors"/>
               
               <f:facet name="afterInvalidField">
                  <s:span>
                     &#160;Error:&#160;
                     <s:message/>
                  </s:span>
               </f:facet>
               <f:facet name="aroundInvalidField">
                  <s:span styleClass="errors"/>
               </f:facet>
               
               <s:validateAll>
                 
                  <div>
                     <h:outputLabel for="body">Fichier (taille maximal 5Mo): </h:outputLabel>
                  </div>
                  <div class="hilite">
                    
                        <s:fileUpload data="#{uploadedFile.uploadedFile}" fileName="#{uploadedFile.pictureName}"/>            
                  </div>
               </s:validateAll>
               
               <div>
                  <h:commandButton action="#{uploadedFile.parse}" value="Ajouter" rendered="#{!imageEntryHome.managed}"/>
                  <h:commandButton value="Enregistrer" rendered="#{imageEntryHome.managed}"/>
               </div>
      
            </h:form>
         </div>
      </ui:define>
      
      </ui:composition>



      And my action



      @Name("uploadedFile")
      public class UploadedFile {
      
           private byte[] uploadedFile;
           
           private String pictureName;     
      
           /**
            * @return the pictureName
            */
           public String getPictureName() {
                return pictureName;
           }
      
           /**
            * @param pictureName the pictureName to set
            */
           public void setPictureName(String pictureName) {
                this.pictureName = pictureName;
           }
      
           /**
            * @return the picture
            */
           public byte[] getUploadedFile() {
                return uploadedFile;
           }
      
           /**
            * @param picture the picture to set
            */
           public void setUploadedFile(byte[] uploadedFile) {
                this.uploadedFile = uploadedFile;
           }
           
           public void parse() throws Exception {
                System.out.println(pictureName);
                if(uploadedFile != null)
                     System.out.println("size = " + uploadedFile.length);
                else
                     System.out.println("uploadedFile is null");
           }     
      }


      I've got always uploadedFile is null message.


      Any idea ?
      Thanks

        1 2 Previous Next