YACOSWeb : Commit de la version démo améliorée
ChoosePreferences fonctionnel ! Plein de petites corrections dans pas mal d'endroit, referez-vous aux changelog de chaque fichier pour plus de détails
This commit is contained in:
@@ -23,15 +23,15 @@
|
||||
<h2 align="center"><fmt:message key="preference.title" /></h2>
|
||||
|
||||
|
||||
<form:form method="post" commandName="choosePreference">
|
||||
<c:if test="${empty requestScope['articleList']}">
|
||||
<form:form method="post" commandName="choosePreference">
|
||||
<c:if test="${not empty articleList}">
|
||||
<table>
|
||||
<c:forEach items="${articleList}" var="article" varStatus="i">
|
||||
|
||||
<tr>
|
||||
<td><a href="<c:url value="detailArticle.htm"/>">${article.title}</a></td>
|
||||
<form:hidden path="preferences[${i.index}].article" />
|
||||
<form:hidden path="preferences[${i.index}].pcMember" />
|
||||
<form:hidden path="preferences[${i.index}].article.id" />
|
||||
<form:hidden path="preferences[${i.index}].pcMember.login" />
|
||||
<td><fmt:message key="preference.like"/></td>
|
||||
<td><form:radiobutton path="preferences[${i.index}].preference" value="Like"/></td>
|
||||
<td><fmt:message key="preference.indifferent"/></td>
|
||||
@@ -41,7 +41,7 @@
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
<input type="submit" value="<fmt:message key="button.OK"/>"/>
|
||||
<input type="submit" name="submit" value="<fmt:message key="button.OK"/>"/>
|
||||
</c:if>
|
||||
</form:form>
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ function Supprimer(form) {
|
||||
|
||||
<jsp:include page="/WEB-INF/jsp/header.jsp" />
|
||||
|
||||
|
||||
<div class="mainBloc">
|
||||
<div class="header"> </div>
|
||||
<div class="content">
|
||||
@@ -31,7 +32,6 @@ function Supprimer(form) {
|
||||
|
||||
|
||||
<h2 align="center"><fmt:message key="submission.title" /></h2>
|
||||
|
||||
<form:form method="post" enctype="multipart/form-data" commandName="submissionArticle">
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<property name="commandName" value="submissionArticle" />
|
||||
<property name="commandClass" value="org.yacos.web.author.form.FormSubmission" />
|
||||
<property name="formView" value="submissionArticle" />
|
||||
<property name="successView" value="submissionArticleOK.htm" />
|
||||
<property name="successView" value="listArticle.htm" />
|
||||
<property name="articleManager" ref="articleManager" />
|
||||
</bean>
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
<property name="commandClass" value="org.yacos.web.PCmember.form.FormPreference" />
|
||||
<property name="formView" value="choosePreference" />
|
||||
<property name="successView" value="choosePreferenceOK" />
|
||||
<property name="articleManager" ref="articleManager" />
|
||||
<property name="articleManager" ref="articleManager" />
|
||||
<property name="usersManager" ref="usersManager" />
|
||||
</bean>
|
||||
|
||||
<bean name="/dispatchArticle.htm" class="org.yacos.web.PCmember.controller.DispatchArticleController">
|
||||
@@ -72,6 +73,7 @@
|
||||
<property name="basename" value="messages" />
|
||||
</bean>
|
||||
|
||||
<jee:jndi-lookup id="articleManager" jndi-name="ArticleManagerBean/remote" cache="true"/>
|
||||
<jee:jndi-lookup id="articleManager" jndi-name="ArticleManagerBean/remote" cache="true"/>
|
||||
<jee:jndi-lookup id="usersManager" jndi-name="UsersManagerBean/remote" cache="true"/>
|
||||
|
||||
</beans>
|
||||
@@ -3,20 +3,17 @@ package org.yacos.web.PCmember.controller;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
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.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
import org.springframework.web.servlet.view.RedirectView;
|
||||
|
||||
import org.yacos.core.article.*;
|
||||
import org.yacos.core.users.IUsersManager;
|
||||
import org.yacos.core.users.User;
|
||||
//import org.yacos.web.author.form.*;
|
||||
import org.yacos.web.PCmember.form.FormPreference;
|
||||
|
||||
@@ -26,21 +23,34 @@ public class ChoosePreferenceController extends SimpleFormController {
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private IArticleManager articleManager;
|
||||
private IUsersManager usersManager;
|
||||
|
||||
@Override
|
||||
protected Object formBackingObject(HttpServletRequest request)
|
||||
throws Exception {
|
||||
|
||||
List<Article> articleList=new ArrayList<Article>();
|
||||
|
||||
Article a=new Article(1,"j2ee in action","j2ee discussion","","",null,1);
|
||||
Article b=new Article(2,"php in action","php discussion","","",null,1);
|
||||
articleList.add(a);
|
||||
articleList.add(b);
|
||||
List<Article> articleList=articleManager.getArticles();
|
||||
|
||||
getServletContext().setAttribute("articleList", articleList);
|
||||
|
||||
return super.formBackingObject(request);
|
||||
User toto = usersManager.getUser("toto");
|
||||
ArrayList<Preference> preferencesList = new ArrayList<Preference>();
|
||||
Preference pref;
|
||||
for(Article article : articleList){
|
||||
pref = articleManager.getArticlePreferenceForUser(article, toto.getLogin());
|
||||
if(pref == null){
|
||||
pref = new Preference();
|
||||
pref.setArticle(article);
|
||||
pref.setPcMember(toto);
|
||||
pref.setPreference("Indifferent");
|
||||
}
|
||||
preferencesList.add(pref);
|
||||
}
|
||||
|
||||
FormPreference preferences = new FormPreference();
|
||||
preferences.setPreferences(preferencesList);
|
||||
|
||||
return preferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,8 +61,14 @@ public class ChoosePreferenceController extends SimpleFormController {
|
||||
FormPreference fp=(FormPreference) command;
|
||||
|
||||
List<Preference> listPreference=fp.getPreferences();
|
||||
// to do with the part of core using preferenceManager
|
||||
System.out.println("wangjialin");
|
||||
|
||||
for(Preference preference : listPreference){
|
||||
articleManager.addArticlePreference(
|
||||
preference.getArticle().getId(),
|
||||
preference.getPcMember().getLogin(),
|
||||
preference.getPreference());
|
||||
}
|
||||
|
||||
return new ModelAndView("choosePreferenceOK");
|
||||
|
||||
}
|
||||
@@ -65,5 +81,11 @@ public class ChoosePreferenceController extends SimpleFormController {
|
||||
this.articleManager = articleManager;
|
||||
}
|
||||
|
||||
public IUsersManager getUsersManager() {
|
||||
return usersManager;
|
||||
}
|
||||
|
||||
public void setUsersManager(IUsersManager usersManager) {
|
||||
this.usersManager = usersManager;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.yacos.web.PCmember.form;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.yacos.core.article.Preference;
|
||||
@@ -7,16 +8,15 @@ import org.yacos.core.article.Preference;
|
||||
|
||||
|
||||
public class FormPreference {
|
||||
private List<Preference> preferences = new AutoInitArrayList <Preference> (Preference.class );
|
||||
private List<Preference> preferences = new ArrayList<Preference>();
|
||||
|
||||
public List<Preference> getPreferences()
|
||||
{
|
||||
return preferences;
|
||||
}
|
||||
|
||||
public void setPreferences(List<Preference> preferences)
|
||||
}
|
||||
|
||||
public void setPreferences(List<Preference> preferences)
|
||||
{
|
||||
this.preferences = preferences;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -36,7 +37,7 @@ public class SArticleController extends SimpleFormController {
|
||||
String theme = ((FormSubmission) command).getTheme();
|
||||
String mainauthor = ((FormSubmission) command).getMainauthor();
|
||||
String secondaryauthor = ((FormSubmission) command).getSecondaryauthor();
|
||||
String liste = ((FormSubmission) command).getListe();
|
||||
List<String> liste = ((FormSubmission) command).getListe();
|
||||
|
||||
String nomFile="";
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.yacos.web.author.form;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -11,7 +12,7 @@ public class FormSubmission {
|
||||
private String theme;
|
||||
private String mainauthor;
|
||||
private String secondaryauthor;
|
||||
private String liste;
|
||||
private ArrayList<String> liste;
|
||||
|
||||
public FormSubmission() {
|
||||
|
||||
@@ -50,11 +51,11 @@ public class FormSubmission {
|
||||
this.secondaryauthor = secondaryauthor;
|
||||
}
|
||||
|
||||
public String getListe() {
|
||||
public List<String> getListe() {
|
||||
return liste;
|
||||
}
|
||||
|
||||
public void setListe(String liste) {
|
||||
public void setListe(ArrayList<String> liste) {
|
||||
this.liste = liste;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user