Changement de la méthode pour l'envoie du fichier...
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow xmlns="http://www.springframework.org/schema/webflow"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/webflow
|
||||
http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd">
|
||||
|
||||
<start-state idref="selectFile"/>
|
||||
|
||||
<view-state id="selectFile" view="submissionArticleFile">
|
||||
<transition on="submit" to="uploadFile"/>
|
||||
</view-state>
|
||||
|
||||
<action-state id="uploadFile">
|
||||
<action bean="uploadAction"/>
|
||||
<transition on="success" to="selectFile">
|
||||
<set attribute="fileUploaded" scope="flash" value="true"/>
|
||||
</transition>
|
||||
<transition on="error" to="selectFile"/>
|
||||
</action-state>
|
||||
|
||||
</flow>
|
||||
@@ -5,13 +5,25 @@
|
||||
|
||||
<head>
|
||||
<title><fmt:message key="title" /></title>
|
||||
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
function Ajouter(form) {
|
||||
var o=new Option(form.mainauthor.value);
|
||||
form.liste.options[form.liste.options.length]=o;
|
||||
}
|
||||
function Ajouter2(form) {
|
||||
var o=new Option(form.secondaryauthor.value);
|
||||
form.liste.options[form.liste.options.length]=o;
|
||||
}
|
||||
</SCRIPT>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h2 align="center"><fmt:message key="submission.title" /></h2>
|
||||
|
||||
<form:form method="post" commandName="submissionArticle">
|
||||
<form:form method="post" enctype="multipart/form-data" commandName="submissionArticle">
|
||||
|
||||
|
||||
<fmt:message key="form.submission.article.title" /> <form:input path="title"/> <br/><br />
|
||||
@@ -20,12 +32,21 @@
|
||||
<hr /> <br />
|
||||
|
||||
<fmt:message key="form.submission.listauthor" /> <br /><br />
|
||||
<fmt:message key="form.submission.mainauthor" /> <form:input path="mainauthor"/> <input type="submit" name="addMain" value=<fmt:message key="button.add" />> <br/><br />
|
||||
<fmt:message key="form.submission.secondaryauthor" /> <form:input path="secondaryauthor"/> <input type="submit" name="addSecondary" value=<fmt:message key="button.add" />> <br/><br />
|
||||
<fmt:message key="form.submission.mainauthor" /> <form:input path="mainauthor" />
|
||||
<input type="button" name="addMain" onClick="Ajouter(this.form)" value=<fmt:message key="button.add" />> <br/><br />
|
||||
<fmt:message key="form.submission.secondaryauthor" /> <form:input path="secondaryauthor" />
|
||||
<input type="button" name="addSecondary" onClick="Ajouter2(this.form)" value=<fmt:message key="button.add" />> <br/><br />
|
||||
|
||||
<textarea name="AreaAuthor" rows=10 cols=40></textarea> <br />
|
||||
<form:select path="liste" size="5" itemValue="test">
|
||||
|
||||
</form:select>
|
||||
<br />
|
||||
|
||||
<hr /> <br />
|
||||
<hr />
|
||||
|
||||
File : <input type="file" name="file"/>
|
||||
|
||||
<br /><br />
|
||||
|
||||
<input type="submit" value=<fmt:message key="button.cancel" />>
|
||||
<input type="submit" value=<fmt:message key="button.OK" />> <br/><br/>
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<%@ page contentType="text/html" %>
|
||||
<%@ page session="true" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Insert title here</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<form name="submitForm" method="post" enctype="multipart/form-data" action="submissionArticleOK.htm">
|
||||
<table>
|
||||
<c:if test="${fileUploaded}">
|
||||
<p>File uploaded succesfully.</p>
|
||||
<c:if test="${!empty(file)}">
|
||||
<pre style="border: solid 1px;">${file}</pre>
|
||||
</c:if>
|
||||
</c:if>
|
||||
<tr>
|
||||
<td>
|
||||
File:
|
||||
</td>
|
||||
<td>
|
||||
<input type="file" name="file">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="buttonBar">
|
||||
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}">
|
||||
<input type="submit" class="button" name="_eventId_submit" value="Upload">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,13 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:flow="http://www.springframework.org/schema/webflow-config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/webflow-config
|
||||
http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/jee
|
||||
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
|
||||
|
||||
@@ -22,17 +19,17 @@
|
||||
<property name="commandName" value="submissionArticle" />
|
||||
<property name="commandClass" value="org.yacos.web.author.form.FormSubmission" />
|
||||
<property name="formView" value="submissionArticle" />
|
||||
<property name="successView" value="submissionArticleFile.htm?_flowId=fileupload" />
|
||||
<property name="successView" value="submissionArticleOK.htm" />
|
||||
<property name="articleManager" ref="articleManager" />
|
||||
</bean>
|
||||
|
||||
<bean name="/choosePreference.htm" class="org.yacos.web.PCmember.controller.ChoosePreferenceControl">
|
||||
<!-- <bean name="/choosePreference.htm" class="org.yacos.web.PCmember.controller.ChoosePreferenceControl">
|
||||
<property name="commandName" value="choose"/>
|
||||
<property name="commandClass" value="org.yacos.web.author.form.FormPreference" />
|
||||
<property name="formView" value="choosePreference" />
|
||||
<property name="successView" value="choosePreferenceOK" />
|
||||
<property name="articleManager" ref="articleManager" />
|
||||
</bean>
|
||||
</bean> -->
|
||||
|
||||
<bean id="viewResolver"
|
||||
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||
@@ -43,28 +40,11 @@
|
||||
<property name="suffix" value=".jsp"></property>
|
||||
</bean>
|
||||
|
||||
<bean name="/submissionArticleFile.htm" class="org.springframework.webflow.executor.mvc.FlowController">
|
||||
<property name="flowExecutor" ref="flowExecutor" />
|
||||
</bean>
|
||||
|
||||
<!-- Launches new flow executions and resumes existing executions. -->
|
||||
<flow:executor id="flowExecutor" registry-ref="flowRegistry" repository-type="singlekey"/>
|
||||
|
||||
<!-- Creates the registry of flow definitions for this application -->
|
||||
<flow:registry id="flowRegistry">
|
||||
<flow:location path="/WEB-INF/fileupload.xml" />
|
||||
</flow:registry>
|
||||
|
||||
<!--
|
||||
Support for multipart requests using commons file upload
|
||||
Make sure you have the commons-fileupload.jar in your classpath
|
||||
-->
|
||||
|
||||
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
||||
<!-- Limit uploads to small (5KB) files for this sample -->
|
||||
<property name="maxUploadSize" value="5120" />
|
||||
<property name="maxUploadSize" value="100000" />
|
||||
</bean>
|
||||
|
||||
<bean id="uploadAction" class="org.yacos.web.utils.FileUploadAction" />
|
||||
|
||||
|
||||
<bean id="messageSource"
|
||||
class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package org.yacos.web.author.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
import org.springframework.web.servlet.view.RedirectView;
|
||||
@@ -26,8 +29,18 @@ public class SArticleController extends SimpleFormController {
|
||||
String theme = ((FormSubmission) command).getTheme();
|
||||
String mainauthor = ((FormSubmission) command).getMainauthor();
|
||||
String secondaryauthor = ((FormSubmission) command).getSecondaryauthor();
|
||||
String file = ((FormSubmission) command).getFile();
|
||||
//String file = ((FormSubmission) command).getFile();
|
||||
|
||||
String liste = ((FormSubmission) command).getListe();
|
||||
|
||||
System.out.println(liste);
|
||||
|
||||
|
||||
// let's see if there's content there
|
||||
MultipartFile file = ((FormSubmission) command).getFile();
|
||||
if (file == null) {
|
||||
// hmm, that's strange, the user did not upload anything
|
||||
}
|
||||
|
||||
Article a = new Article(0, title, theme, "", mainauthor, null, 1);
|
||||
articleManager.addArticle(a);
|
||||
@@ -40,8 +53,7 @@ public class SArticleController extends SimpleFormController {
|
||||
myArticle.setTitle("Le titre de l'article");
|
||||
myArticle.setTheme("Le theme de l'article");
|
||||
myArticle.setMainauthor("L'auteur principal");
|
||||
myArticle.setSecondaryauthor("Les auteurs n°2");
|
||||
myArticle.setFile("Le fichier");
|
||||
myArticle.setSecondaryauthor("Les auteurs secondaires");
|
||||
return myArticle;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,29 @@
|
||||
package org.yacos.web.author.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public class FormSubmission {
|
||||
|
||||
private MultipartFile file;
|
||||
private String title;
|
||||
private String theme;
|
||||
private String mainauthor;
|
||||
private String secondaryauthor;
|
||||
private String file;
|
||||
private String liste;
|
||||
|
||||
public FormSubmission() {
|
||||
|
||||
}
|
||||
|
||||
public void setFile(MultipartFile file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public MultipartFile getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
@@ -36,11 +49,13 @@ public class FormSubmission {
|
||||
public void setSecondaryauthor(String secondaryauthor) {
|
||||
this.secondaryauthor = secondaryauthor;
|
||||
}
|
||||
public String getFile() {
|
||||
return file;
|
||||
|
||||
public String getListe() {
|
||||
return liste;
|
||||
}
|
||||
public void setFile(String file) {
|
||||
this.file = file;
|
||||
|
||||
public void setListe(String liste) {
|
||||
this.liste = liste;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.yacos.web.utils;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.webflow.action.AbstractAction;
|
||||
import org.springframework.webflow.execution.Event;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
|
||||
public class FileUploadAction extends AbstractAction {
|
||||
|
||||
protected Event doExecute(RequestContext context) throws Exception {
|
||||
MultipartFile file = context.getRequestParameters().getRequiredMultipartFile("file");
|
||||
if (file.getSize() > 0) {
|
||||
// data was uploaded
|
||||
context.getFlashScope().put("file", new String(file.getBytes()));
|
||||
return success();
|
||||
} else {
|
||||
return error();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user