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

    1   /*
    2    * $Id: FileUploadAction.java 476710 2006-11-19 05:05:14Z mrdon $
    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   package org.apache.struts2.showcase.fileupload;
   22   
   23   import java.io.File;
   24   
   25   import com.opensymphony.xwork2.ActionSupport;
   26   
   27   /**
   28    * Show case File Upload example's action. <code>FileUploadAction</code>
   29    *
   30    */
   31   public class FileUploadAction extends ActionSupport {
   32   
   33       private static final long serialVersionUID = 5156288255337069381L;
   34   
   35       private String contentType;
   36       private File upload;
   37       private String fileName;
   38       private String caption;
   39   
   40       // since we are using <s:file name="upload" .../> the file name will be
   41       // obtained through getter/setter of <file-tag-name>FileName
   42       public String getUploadFileName() {
   43           return fileName;
   44       }
   45       public void setUploadFileName(String fileName) {
   46           this.fileName = fileName;
   47       }
   48   
   49   
   50       // since we are using <s:file name="upload" ... /> the content type will be
   51       // obtained through getter/setter of <file-tag-name>ContentType
   52       public String getUploadContentType() {
   53           return contentType;
   54       }
   55       public void setUploadContentType(String contentType) {
   56           this.contentType = contentType;
   57       }
   58   
   59   
   60       // since we are using <s:file name="upload" ... /> the File itself will be
   61       // obtained through getter/setter of <file-tag-name>
   62       public File getUpload() {
   63           return upload;
   64       }
   65       public void setUpload(File upload) {
   66           this.upload = upload;
   67       }
   68   
   69   
   70       public String getCaption() {
   71           return caption;
   72       }
   73       public void setCaption(String caption) {
   74           this.caption = caption;
   75       }
   76   
   77       public String input() throws Exception {
   78           return SUCCESS;
   79       }
   80   
   81       public String upload() throws Exception  {
   82           return SUCCESS;
   83       }
   84   
   85   }

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