From 8f3ad3529843de18d0da8fcf392924024ce2f5ec Mon Sep 17 00:00:00 2001 From: Frederic Debuire Date: Mon, 17 Dec 2007 22:05:21 +0000 Subject: [PATCH] Ajout de l'URL dans la liste des articles. Petite gestion quand y'a pas de file :s --- .../WebContent/WEB-INF/jsp/listArticle.jsp | 70 +++++++++---------- .../WEB-INF/jsp/submissionArticle.jsp | 3 +- .../WEB-INF/jsp/submissionArticleOK.jsp | 10 +-- YACOSWeb/WebContent/stylesheets/base.css | 20 ++++-- .../author/controller/SArticleController.java | 59 ++++++++++------ 5 files changed, 88 insertions(+), 74 deletions(-) diff --git a/YACOSWeb/WebContent/WEB-INF/jsp/listArticle.jsp b/YACOSWeb/WebContent/WEB-INF/jsp/listArticle.jsp index 42964a0..383ba64 100644 --- a/YACOSWeb/WebContent/WEB-INF/jsp/listArticle.jsp +++ b/YACOSWeb/WebContent/WEB-INF/jsp/listArticle.jsp @@ -1,39 +1,33 @@ -<%@ include file="/WEB-INF/jsp/include.jsp"%> -<%@ page session="false" %> - - - - - - <fmt:message key="title"/> - - - - - - -
-
 
-
- - -
- - - - -
    -
  • ${article.title}
  • -
  • ${article.mainAuthor}
  • -
  • ${article.topic}
  • -
  • ${article.URL_article}
  • -
-
- -
-
- -
- - +<%@ include file="/WEB-INF/jsp/include.jsp"%> +<%@ page session="false"%> + + + + + +<fmt:message key="title" /> + + + + + + +
+
 
+
+
+ + + +
+
+ +
+ + \ No newline at end of file diff --git a/YACOSWeb/WebContent/WEB-INF/jsp/submissionArticle.jsp b/YACOSWeb/WebContent/WEB-INF/jsp/submissionArticle.jsp index d180afa..3269bf8 100644 --- a/YACOSWeb/WebContent/WEB-INF/jsp/submissionArticle.jsp +++ b/YACOSWeb/WebContent/WEB-INF/jsp/submissionArticle.jsp @@ -47,7 +47,8 @@ function Supprimer(form) { - + +


diff --git a/YACOSWeb/WebContent/WEB-INF/jsp/submissionArticleOK.jsp b/YACOSWeb/WebContent/WEB-INF/jsp/submissionArticleOK.jsp index 4fdc215..cbf6175 100644 --- a/YACOSWeb/WebContent/WEB-INF/jsp/submissionArticleOK.jsp +++ b/YACOSWeb/WebContent/WEB-INF/jsp/submissionArticleOK.jsp @@ -20,14 +20,8 @@
-Soumission OK - - -

File uploaded succesfully.

- -
${file}
-
-
+Soumission OK +
">Home diff --git a/YACOSWeb/WebContent/stylesheets/base.css b/YACOSWeb/WebContent/stylesheets/base.css index 35b3c73..5a0eeab 100644 --- a/YACOSWeb/WebContent/stylesheets/base.css +++ b/YACOSWeb/WebContent/stylesheets/base.css @@ -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; } \ No newline at end of file diff --git a/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java b/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java index 5f26594..9e1e978 100644 --- a/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java +++ b/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java @@ -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()));