Ajout de l'URL dans la liste des articles.

Petite gestion quand y'a pas de file :s
This commit is contained in:
Frederic Debuire
2007-12-17 22:05:21 +00:00
parent 8cf25a10a2
commit 8f3ad35298
5 changed files with 88 additions and 74 deletions

View File

@@ -14,22 +14,16 @@
<div class="mainBloc">
<div class="header">&nbsp;</div>
<div class="content">
<jsp:include page="/WEB-INF/jsp/menu.jsp" />
<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>
<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">&nbsp;</div>

View File

@@ -48,6 +48,7 @@ function Supprimer(form) {
<form:select path="liste" size="5" ondblclick="Supprimer(this.form)" multiple="true">
</form:select>
<br /><br />
<hr />

View File

@@ -21,13 +21,7 @@
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>
<br />
<a href="<c:url value="main.htm"/>">Home</a>

View File

@@ -116,13 +116,21 @@ body {
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%;
padding-bottom: 5px;
}
ul.article li {
width: 100%;
list-style: none;
}
@@ -134,6 +142,10 @@ ul.article .author {
font-size: small;
}
ul.article .article_url {
font-size: smaller;
ul.article .topic {
font-size: small;
}
ul.article .article_url {
font-size: small;
}

View File

@@ -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;
@@ -24,35 +28,44 @@ public class SArticleController extends SimpleFormController {
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);
String nomFile="";
// let's see if there's content there
try {
MultipartFile file = ((FormSubmission) command).getFile();
if (file == null) {
// hmm, that's strange, the user did not upload anything
}
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, "", mainauthor, null, 1);
Article a = new Article(0, title, theme, nomFile, mainauthor, null, 1);
articleManager.addArticle(a);
return new ModelAndView(new RedirectView(getSuccessView()));