Ajout de l'URL dans la liste des articles.
Petite gestion quand y'a pas de file :s
This commit is contained in:
@@ -1,39 +1,33 @@
|
||||
<%@ include file="/WEB-INF/jsp/include.jsp"%>
|
||||
<%@ page session="false" %>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<title><fmt:message key="title"/></title>
|
||||
<link rel="stylesheet" href="./stylesheets/base.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<jsp:include page="/WEB-INF/jsp/header.jsp" />
|
||||
|
||||
<div class="mainBloc">
|
||||
<div class="header"> </div>
|
||||
<div class="content">
|
||||
|
||||
<jsp:include page="/WEB-INF/jsp/menu.jsp" />
|
||||
<div id="main_content">
|
||||
|
||||
|
||||
|
||||
<c:forEach items="${listArticle}" var="article">
|
||||
<ul class="article">
|
||||
<li class="title">${article.title}</li>
|
||||
<li class="author">${article.mainAuthor}</li>
|
||||
<li class="topic">${article.topic}</li>
|
||||
<li class="article_url">${article.URL_article}</li>
|
||||
</ul>
|
||||
</c:forEach>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer"> </div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<%@ include file="/WEB-INF/jsp/include.jsp"%>
|
||||
<%@ page session="false"%>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title><fmt:message key="title" /></title>
|
||||
<link rel="stylesheet" href="./stylesheets/base.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<jsp:include page="/WEB-INF/jsp/header.jsp" />
|
||||
|
||||
<div class="mainBloc">
|
||||
<div class="header"> </div>
|
||||
<div class="content"><jsp:include page="/WEB-INF/jsp/menu.jsp" />
|
||||
<div id="main_content">
|
||||
<c:forEach items="${listArticle}" var="article">
|
||||
<ul class="article">
|
||||
<li class="title">${article.title}</li>
|
||||
<li class="author">Author: ${article.mainAuthor}</li>
|
||||
<li class="topic">Topic: ${article.topic}</li>
|
||||
<li class="article_url"><a href="<c:url value="${article.URL_article}"/>">Download the article</a></li>
|
||||
</ul>
|
||||
</c:forEach>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer"> </div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -47,7 +47,8 @@ function Supprimer(form) {
|
||||
|
||||
<form:select path="liste" size="5" ondblclick="Supprimer(this.form)" multiple="true">
|
||||
|
||||
</form:select>
|
||||
</form:select>
|
||||
|
||||
<br /><br />
|
||||
|
||||
<hr />
|
||||
|
||||
@@ -20,14 +20,8 @@
|
||||
<div id="main_content">
|
||||
|
||||
|
||||
Soumission OK
|
||||
|
||||
<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>
|
||||
Soumission OK
|
||||
<br />
|
||||
|
||||
<a href="<c:url value="main.htm"/>">Home</a>
|
||||
|
||||
|
||||
@@ -115,14 +115,22 @@ body {
|
||||
display: table-cell;
|
||||
width: 640px;
|
||||
}
|
||||
|
||||
.article a {
|
||||
text-decoration: none;
|
||||
color: #002bb8;
|
||||
background: none;
|
||||
}
|
||||
.article a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
ul.article {
|
||||
border-bottom : thin solid #666;
|
||||
width: 100%;
|
||||
border-bottom : thin solid #666;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
ul.article li {
|
||||
width: 100%;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
@@ -132,8 +140,12 @@ ul.article .title {
|
||||
|
||||
ul.article .author {
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
ul.article .topic {
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
ul.article .article_url {
|
||||
font-size: smaller;
|
||||
font-size: small;
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
package org.yacos.web.author.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
@@ -22,37 +26,46 @@ public class SArticleController extends SimpleFormController {
|
||||
/** Logger for this class and subclasses */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private IArticleManager articleManager;
|
||||
private IArticleManager articleManager;
|
||||
|
||||
public ModelAndView onSubmit(Object command)
|
||||
throws ServletException, IllegalStateException, IOException {
|
||||
public ModelAndView onSubmit(HttpServletRequest request,
|
||||
HttpServletResponse response, Object command, BindException errors)
|
||||
throws ServletException, IllegalStateException {
|
||||
|
||||
String title = ((FormSubmission) command).getTitle();
|
||||
String theme = ((FormSubmission) command).getTheme();
|
||||
String mainauthor = ((FormSubmission) command).getMainauthor();
|
||||
String secondaryauthor = ((FormSubmission) command).getSecondaryauthor();
|
||||
//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
|
||||
}
|
||||
|
||||
byte b[] = file.getBytes();
|
||||
File file2 = new File(file.getOriginalFilename());
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(file2);
|
||||
|
||||
fos.write(b);
|
||||
fos.close();
|
||||
|
||||
|
||||
Article a = new Article(0, title, theme, "", mainauthor, null, 1);
|
||||
String nomFile="";
|
||||
|
||||
try {
|
||||
MultipartFile file = ((FormSubmission) command).getFile();
|
||||
if (file == null) {
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
byte b[] = file.getBytes();
|
||||
File file2 = new File(file.getOriginalFilename());
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(file2);
|
||||
|
||||
URL testURL = file2.toURL();
|
||||
nomFile = testURL.toString();
|
||||
|
||||
fos.write(b);
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
System.out.println(e);
|
||||
} catch (IOException e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
Article a = new Article(0, title, theme, nomFile, mainauthor, null, 1);
|
||||
articleManager.addArticle(a);
|
||||
|
||||
return new ModelAndView(new RedirectView(getSuccessView()));
|
||||
|
||||
Reference in New Issue
Block a user