Commits

Anonymous committed 9b9fa1b

* file upload example
* type converter will now stop if there is no need to convert

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@505573baa09-0c28-0410-bef9-dab3c582ae83

Comments (0)

Files changed (5)

src/etc/example/file-upload.xml

+<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd">
+
+<xwork>
+    <package name="fileUpload" extends="webwork-default" namespace="/fileUpload">
+        <interceptors>
+            <interceptor-stack name="fileUploadStack">
+                <interceptor-ref name="fileUpload"/>
+                <interceptor-ref name="defaultStack"/>
+            </interceptor-stack>
+        </interceptors>
+        <default-interceptor-ref name="fileUploadStack"/>
+        <action name="fileUpload" class="com.opensymphony.webwork.example.fileUpload.FileUploadAction">
+            <result name="success">success.jsp</result>
+            <result name="input">input.jsp</result>
+        </action>
+    </package>
+</xwork>

src/etc/example/xwork.xml

             <result name="success" type="dispatcher">/select.jsp</result>
         </action>
 
-        <action name="formTest" class="com.opensymphony.webwork.example.FormAction" method="processForm" >
+        <action name="formTest" class="com.opensymphony.webwork.example.FormAction" method="processForm">
             <result name="success" type="dispatcher">
                 <param name="location">/form.jsp</param>
             </result>
-             <result name="invalid.token" type="dispatcher">
+            <result name="invalid.token" type="dispatcher">
                 <param name="location">/form.jsp</param>
             </result>
 
             <interceptor-ref name="token"/>
         </action>
 
-        <action name="formTest2" class="com.opensymphony.webwork.example.FormAction" method="processForm" >
+        <action name="formTest2" class="com.opensymphony.webwork.example.FormAction" method="processForm">
             <result name="success" type="dispatcher">
                 <param name="location">/form2-success.jsp</param>
             </result>
             <result name="input">javascript-input.jsp</result>
         </action>
 
-		 <!-- JasperReport Basic Test Actions -->
+        <!-- JasperReport Basic Test Actions -->
         <action name="jasperTest" class="com.opensymphony.webwork.example.jasperreports.OrderListAction">
             <result name="success" type="jasper">
                 <param name="location">orderList.jasper</param>
 
     <include file="i18n.xml"/>
 
+    <include file="file-upload.xml"/>
+
 </xwork>

src/example/com/opensymphony/webwork/example/fileUpload/FileUploadAction.java

+package com.opensymphony.webwork.example.fileUpload;
+
+import com.opensymphony.xwork.ActionSupport;
+
+import java.io.File;
+
+public class FileUploadAction extends ActionSupport {
+    File file;
+    String fileContentType;
+    String fileFileName;
+    File[] files;
+    String[] filesContentType;
+    String[] filesFileName;
+
+    public String execute() throws Exception {
+
+        return SUCCESS;
+    }
+
+    public String doDefault() throws Exception {
+        return INPUT;
+    }
+
+    public void setFile(File file) {
+        this.file = file;
+    }
+
+    public void setFileContentType(String fileContentType) {
+        this.fileContentType = fileContentType;
+    }
+
+    public void setFileFileName(String fileFileName) {
+        this.fileFileName = fileFileName;
+    }
+
+    public void setFiles(File[] files) {
+        this.files = files;
+    }
+
+    public void setFilesContentType(String[] filesContentType) {
+        this.filesContentType = filesContentType;
+    }
+
+    public void setFilesFileName(String[] filesFileName) {
+        this.filesFileName = filesFileName;
+    }
+}

src/webapp/fileUpload/input.jsp

+<%@ taglib prefix="ww" uri="webwork" %>
+<html>
+  <head><title>File Upload</title></head>
+  <body>
+
+  <ww:form action="'fileUpload'" enctype="'multipart/form-data'" method="'post'" >
+    <ww:file label="'File'" name="'file'"/>
+    <ww:file label="'File(s)'" name="'files'"/>
+    <ww:file label="'File(s)'" name="'files'"/>
+    <ww:file label="'File(s)'" name="'files'"/>
+    <ww:submit value="'Upload'"/>
+  </ww:form>
+
+  </body>
+</html>

src/webapp/fileUpload/success.jsp

+<html>
+  <head><title>Success</title></head>
+  <body>SUCCESS!</body>
+</html>