Home » struts-2.1.8.1-src » org.apache » struts2 » showcase » fileupload » [javadoc | source]

    1   /*
    2    * $Id: MultipleFileUploadUsingListAction.java 660522 2008-05-27 14:08:00Z jholmes $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
   10    * with the License.  You may obtain a copy of the License at
   11    *
   12    *  http://www.apache.org/licenses/LICENSE-2.0
   13    *
   14    * Unless required by applicable law or agreed to in writing,
   15    * software distributed under the License is distributed on an
   16    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   17    * KIND, either express or implied.  See the License for the
   18    * specific language governing permissions and limitations
   19    * under the License.
   20    */
   21   // START SNIPPET: entire-file
   22   package org.apache.struts2.showcase.fileupload;
   23   import java.io.File;
   24   import java.util.ArrayList;
   25   import java.util.List;
   26   
   27   import com.opensymphony.xwork2.ActionSupport;
   28   
   29   /**
   30    * Showcase action - multiple file upload using List
   31    * @version $Date: 2008-05-27 10:08:00 -0400 (Tue, 27 May 2008) $ $Id: MultipleFileUploadUsingListAction.java 660522 2008-05-27 14:08:00Z jholmes $
   32    */
   33   public class MultipleFileUploadUsingListAction extends ActionSupport {
   34   
   35       private List<File> uploads = new ArrayList<File>();
   36       private List<String> uploadFileNames = new ArrayList<String>();
   37       private List<String> uploadContentTypes = new ArrayList<String>();
   38   
   39   
   40       public List<File> getUpload() {
   41           return this.uploads;
   42       }
   43       public void setUpload(List<File> uploads) {
   44           this.uploads = uploads;
   45       }
   46   
   47       public List<String> getUploadFileName() {
   48           return this.uploadFileNames;
   49       }
   50       public void setUploadFileName(List<String> uploadFileNames) {
   51           this.uploadFileNames = uploadFileNames;
   52       }
   53   
   54       public List<String> getUploadContentType() {
   55           return this.uploadContentTypes;
   56       }
   57       public void setUploadContentType(List<String> contentTypes) {
   58           this.uploadContentTypes = contentTypes;
   59       }
   60   
   61       public String upload() throws Exception {
   62   
   63           System.out.println("\n\n upload1");
   64           System.out.println("files:");
   65           for (File u: uploads) {
   66               System.out.println("*** "+u+"\t"+u.length());
   67           }
   68           System.out.println("filenames:");
   69           for (String n: uploadFileNames) {
   70               System.out.println("*** "+n);
   71           }
   72           System.out.println("content types:");
   73           for (String c: uploadContentTypes) {
   74               System.out.println("*** "+c);
   75           }
   76           System.out.println("\n\n");
   77           return SUCCESS;
   78       }
   79   }
   80   // END SNIPPET: entire-file

Home » struts-2.1.8.1-src » org.apache » struts2 » showcase » fileupload » [javadoc | source]