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"%>
|
<%@ include file="/WEB-INF/jsp/include.jsp"%>
|
||||||
<%@ page session="false" %>
|
<%@ page session="false"%>
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!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">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<title><fmt:message key="title"/></title>
|
<title><fmt:message key="title" /></title>
|
||||||
<link rel="stylesheet" href="./stylesheets/base.css" type="text/css" />
|
<link rel="stylesheet" href="./stylesheets/base.css" type="text/css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<jsp:include page="/WEB-INF/jsp/header.jsp" />
|
<jsp:include page="/WEB-INF/jsp/header.jsp" />
|
||||||
|
|
||||||
<div class="mainBloc">
|
<div class="mainBloc">
|
||||||
<div class="header"> </div>
|
<div class="header"> </div>
|
||||||
<div class="content">
|
<div class="content"><jsp:include page="/WEB-INF/jsp/menu.jsp" />
|
||||||
|
|
||||||
<jsp:include page="/WEB-INF/jsp/menu.jsp" />
|
|
||||||
<div id="main_content">
|
<div id="main_content">
|
||||||
|
<c:forEach items="${listArticle}" var="article">
|
||||||
|
<ul class="article">
|
||||||
|
<li class="title">${article.title}</li>
|
||||||
<c:forEach items="${listArticle}" var="article">
|
<li class="author">Author: ${article.mainAuthor}</li>
|
||||||
<ul class="article">
|
<li class="topic">Topic: ${article.topic}</li>
|
||||||
<li class="title">${article.title}</li>
|
<li class="article_url"><a href="<c:url value="${article.URL_article}"/>">Download the article</a></li>
|
||||||
<li class="author">${article.mainAuthor}</li>
|
</ul>
|
||||||
<li class="topic">${article.topic}</li>
|
</c:forEach>
|
||||||
<li class="article_url">${article.URL_article}</li>
|
|
||||||
</ul>
|
|
||||||
</c:forEach>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer"> </div>
|
<div class="footer"> </div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -48,6 +48,7 @@ function Supprimer(form) {
|
|||||||
<form:select path="liste" size="5" ondblclick="Supprimer(this.form)" multiple="true">
|
<form:select path="liste" size="5" ondblclick="Supprimer(this.form)" multiple="true">
|
||||||
|
|
||||||
</form:select>
|
</form:select>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|||||||
@@ -21,13 +21,7 @@
|
|||||||
|
|
||||||
|
|
||||||
Soumission OK
|
Soumission OK
|
||||||
|
<br />
|
||||||
<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>
|
|
||||||
|
|
||||||
<a href="<c:url value="main.htm"/>">Home</a>
|
<a href="<c:url value="main.htm"/>">Home</a>
|
||||||
|
|
||||||
|
|||||||
@@ -116,13 +116,21 @@ body {
|
|||||||
width: 640px;
|
width: 640px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.article a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #002bb8;
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
.article a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
ul.article {
|
ul.article {
|
||||||
border-bottom : thin solid #666;
|
border-bottom : thin solid #666;
|
||||||
width: 100%;
|
padding-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.article li {
|
ul.article li {
|
||||||
width: 100%;
|
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +142,10 @@ ul.article .author {
|
|||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.article .article_url {
|
ul.article .topic {
|
||||||
font-size: smaller;
|
font-size: small;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.article .article_url {
|
||||||
|
font-size: small;
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,18 @@
|
|||||||
package org.yacos.web.author.controller;
|
package org.yacos.web.author.controller;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.validation.BindException;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||||
@@ -24,35 +28,44 @@ public class SArticleController extends SimpleFormController {
|
|||||||
|
|
||||||
private IArticleManager articleManager;
|
private IArticleManager articleManager;
|
||||||
|
|
||||||
public ModelAndView onSubmit(Object command)
|
public ModelAndView onSubmit(HttpServletRequest request,
|
||||||
throws ServletException, IllegalStateException, IOException {
|
HttpServletResponse response, Object command, BindException errors)
|
||||||
|
throws ServletException, IllegalStateException {
|
||||||
|
|
||||||
String title = ((FormSubmission) command).getTitle();
|
String title = ((FormSubmission) command).getTitle();
|
||||||
String theme = ((FormSubmission) command).getTheme();
|
String theme = ((FormSubmission) command).getTheme();
|
||||||
String mainauthor = ((FormSubmission) command).getMainauthor();
|
String mainauthor = ((FormSubmission) command).getMainauthor();
|
||||||
String secondaryauthor = ((FormSubmission) command).getSecondaryauthor();
|
String secondaryauthor = ((FormSubmission) command).getSecondaryauthor();
|
||||||
//String file = ((FormSubmission) command).getFile();
|
|
||||||
|
|
||||||
String liste = ((FormSubmission) command).getListe();
|
String liste = ((FormSubmission) command).getListe();
|
||||||
|
|
||||||
System.out.println(liste);
|
String nomFile="";
|
||||||
|
|
||||||
// let's see if there's content there
|
try {
|
||||||
MultipartFile file = ((FormSubmission) command).getFile();
|
MultipartFile file = ((FormSubmission) command).getFile();
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
// hmm, that's strange, the user did not upload anything
|
|
||||||
}
|
|
||||||
|
|
||||||
byte b[] = file.getBytes();
|
}
|
||||||
File file2 = new File(file.getOriginalFilename());
|
else {
|
||||||
|
|
||||||
FileOutputStream fos = new FileOutputStream(file2);
|
byte b[] = file.getBytes();
|
||||||
|
File file2 = new File(file.getOriginalFilename());
|
||||||
|
|
||||||
fos.write(b);
|
FileOutputStream fos = new FileOutputStream(file2);
|
||||||
fos.close();
|
|
||||||
|
|
||||||
|
URL testURL = file2.toURL();
|
||||||
|
nomFile = testURL.toString();
|
||||||
|
|
||||||
Article a = new Article(0, title, theme, "", mainauthor, null, 1);
|
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);
|
articleManager.addArticle(a);
|
||||||
|
|
||||||
return new ModelAndView(new RedirectView(getSuccessView()));
|
return new ModelAndView(new RedirectView(getSuccessView()));
|
||||||
|
|||||||
Reference in New Issue
Block a user