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="mainBloc">
<div class="header">&nbsp;</div> <div class="header">&nbsp;</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"> <c:forEach items="${listArticle}" var="article">
<ul class="article"> <ul class="article">
<li class="title">${article.title}</li> <li class="title">${article.title}</li>
<li class="author">${article.mainAuthor}</li> <li class="author">Author: ${article.mainAuthor}</li>
<li class="topic">${article.topic}</li> <li class="topic">Topic: ${article.topic}</li>
<li class="article_url">${article.URL_article}</li> <li class="article_url"><a href="<c:url value="${article.URL_article}"/>">Download the article</a></li>
</ul> </ul>
</c:forEach> </c:forEach>
</div> </div>
</div> </div>
<div class="footer">&nbsp;</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 path="liste" size="5" ondblclick="Supprimer(this.form)" multiple="true">
</form:select> </form:select>
<br /><br /> <br /><br />
<hr /> <hr />

View File

@@ -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>

View File

@@ -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;
} }

View File

@@ -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
} }
else {
byte b[] = file.getBytes(); byte b[] = file.getBytes();
File file2 = new File(file.getOriginalFilename()); File file2 = new File(file.getOriginalFilename());
FileOutputStream fos = new FileOutputStream(file2); FileOutputStream fos = new FileOutputStream(file2);
URL testURL = file2.toURL();
nomFile = testURL.toString();
fos.write(b); fos.write(b);
fos.close(); 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);
Article a = new Article(0, title, theme, "", mainauthor, null, 1);
articleManager.addArticle(a); articleManager.addArticle(a);
return new ModelAndView(new RedirectView(getSuccessView())); return new ModelAndView(new RedirectView(getSuccessView()));