Début de la validation pour l'ajout de conférence.

L'ajout des membres existant marche.
Policy failures:   
Code warning
- failed on resource ConferenceValidator.java. Reason: Class is a raw type. References to generic type Class<T> should be parameterized, line 10
- failed on resource validation. Reason: Class is a raw type. References to generic type Class<T> should be parameterized, line 10
- failed on resource AddConferenceController.java. Reason: HashSet is a raw type. References to generic type HashSet<E> should be parameterized, line 149
- failed on resource AddConferenceController.java. Reason: Iterator is a raw type. References to generic type Iterator<E> should be parameterized, line 108
- failed on resource AddConferenceController.java. Reason: Iterator is a raw type. References to generic type Iterator<E> should be parameterized, line 115
... and more.  
Override reason:   
go
This commit is contained in:
Frederic Debuire
2008-01-31 14:56:36 +00:00
parent 62b624fde4
commit 444b6934de
9 changed files with 211 additions and 139 deletions

View File

@@ -8,9 +8,9 @@
<form:form commandName="formConference" name="monForm"> <form:form commandName="formConference" name="monForm">
<fmt:message key="conference.title" /> <input type="text" name="title"/> <br/><br /> <fmt:message key="conference.title" /> <form:input path="title"/> <form:errors path="title" /> <br/><br />
<fmt:message key="conference.description" /> <textarea name="description"></textarea> <br/><br /> <fmt:message key="conference.description" /> <form:textarea path="description" /> <form:errors path="description" /> <br/><br />
<fmt:message key="conference.otherInformations" /> <textarea name="otherInformations"></textarea> <br/><br /> <fmt:message key="conference.otherInformations" /> <form:textarea path="otherInformations" /> <br/><br />
<input type="submit" align="middle" name="_target1" value="Next" /> <input type="submit" align="middle" name="_target1" value="Next" />

View File

@@ -12,12 +12,12 @@
<form:form commandName="formConference" name="monForm"> <form:form commandName="formConference" name="monForm">
<fmt:message key="conference2.start" /><input onclick="ds_sh(this);" name="date" style="cursor: text" /><br /><br /> <fmt:message key="conference2.start" /><form:input onclick="ds_sh(this);" path="dateStart" cssStyle="cursor: text" /> <form:errors path="dateStart" /><br /><br />
<fmt:message key="conference2.end" /><input onclick="ds_sh(this);" name="date2" style="cursor: text" /><br /><br /> <fmt:message key="conference2.end" /><form:input onclick="ds_sh(this);" path="dateEnd" cssStyle="cursor: text" /> <form:errors path="dateEnd" /><br /><br />
<br /> <br />
<fmt:message key="conference2.article" /><input onclick="ds_sh(this);" name="date3" style="cursor: text" /><br /><br /> <fmt:message key="conference2.article" /><form:input onclick="ds_sh(this);" path="dateArticle" cssStyle="cursor: text" /> <form:errors path="dateArticle" /><br /><br />
<fmt:message key="conference2.evaluation" /><input onclick="ds_sh(this);" name="date4" style="cursor: text" /><br /><br /> <fmt:message key="conference2.evaluation" /><form:input onclick="ds_sh(this);" path="dateEvaluation" cssStyle="cursor: text" /> <form:errors path="dateEvaluation" /><br /><br />
<input type="submit" name="_target0" value="Back"> <input type="submit" name="_target0" value="Back">

View File

@@ -9,13 +9,17 @@
<form:form commandName="formConference" name="monForm"> <form:form commandName="formConference" name="monForm">
<fieldset><legend>Information</legend> Page's numbers <input <form:errors path="*" />
type="text"> File's type : <select>
<option>PDF</option>
<option>Tex/Latec</option>
<option>Word</option>
</select></fieldset> <fieldset><legend>Information</legend>
Page's numbers <form:input path="pageNumber" />
File's type : <form:select path="fileType">
<form:option value="" />
<form:option value="PDF" />
<form:option value="Tex/Latec" />
<form:option value="Word" />
</form:select></fieldset>
<br /> <br />
@@ -23,7 +27,7 @@
<br /> <br />
Informations compl<70>mentaires : <textarea></textarea> Informations compl<70>mentaires : <form:textarea path="sendInfo" />
<br /> <br />
<br /> <br />

View File

@@ -22,7 +22,7 @@ var peopleCache = { };
var viewed = -1; var viewed = -1;
function fillTable() { function fillTable() {
AddCriteriaJS.getUsers(function(people) { AddCriteriaJS.getUsersFiltered(function(people) {
// Delete all the rows except for the "pattern" row // Delete all the rows except for the "pattern" row
dwr.util.removeAllRows("personbody", { filter:function(tr) { dwr.util.removeAllRows("personbody", { filter:function(tr) {
return (tr.id != "pattern"); return (tr.id != "pattern");
@@ -77,12 +77,22 @@ function deletePerson(eleid) {
if (confirm("Are you sure you want to delete " + person.name + "?")) { if (confirm("Are you sure you want to delete " + person.name + "?")) {
dwr.engine.beginBatch(); dwr.engine.beginBatch();
AddCriteriaJS.deletePerson(person); AddCriteriaJS.deletePerson(person);
filterUser(null, dwr.util.getValue("myfilter"));
fillTable(); fillTable();
fillTable2(); fillTable2();
dwr.engine.endBatch(); dwr.engine.endBatch();
} }
} }
Event.observe(window, 'load', function() {
new Form.Element.Observer('myfilter', 1, filterUser)
});
function filterUser(el, value) {
AddCriteriaJS.fillUser(value);
setTimeout("fillTable()", 500);
}
</script> </script>
</head> </head>
@@ -92,11 +102,8 @@ function deletePerson(eleid) {
<form:form commandName="formConference" name="monForm"> <form:form commandName="formConference" name="monForm">
Filter <input id="myfilter" type="text" />
<table border="1"> <table border="1">
<tr align="right">
<td></td>
<td>Filter <input id="filter" type="text"/></td>
</tr>
<tbody id="personbody"> <tbody id="personbody">
<tr id="pattern" style="display: none;"> <tr id="pattern" style="display: none;">
<td><span id="tablePerson">Person</span></td> <td><span id="tablePerson">Person</span></td>
@@ -106,6 +113,9 @@ function deletePerson(eleid) {
</tr> </tr>
</tbody> </tbody>
</table> </table>
Add a new member <br />
Mail: <input id="mail" type="text" />
<br /> <br />
@@ -123,7 +133,7 @@ function deletePerson(eleid) {
<br /> <br />
<input type="submit" align="middle" name="_target3" value="Back"> <input type="submit" align="middle" name="_target3" value="Back">
<input type="submit" align="middle" name="_finish" value="Next" /> <input type="submit" align="middle" name="_finish" value="Finish" />
</form:form> </form:form>

View File

@@ -43,7 +43,7 @@
<prop key="/dispatchArticle.htm"> <prop key="/dispatchArticle.htm">
DispatchArticleController DispatchArticleController
</prop> </prop>
<prop key="/addConference5.htm"> <!-- <prop key="/addConference5.htm">
AddConferenceController5 AddConferenceController5
</prop> </prop>
<prop key="/addConference4.htm"> <prop key="/addConference4.htm">
@@ -54,7 +54,7 @@
</prop> </prop>
<prop key="/addConference2.htm"> <prop key="/addConference2.htm">
AddConferenceController2 AddConferenceController2
</prop> </prop> -->
<prop key="/addConference.htm"> <prop key="/addConference.htm">
AddConferenceController AddConferenceController
</prop> </prop>
@@ -134,7 +134,7 @@
<property name="conferenceManager" ref="conferenceManager" /> <property name="conferenceManager" ref="conferenceManager" />
</bean> </bean>
<bean id="AddConferenceController5" <!-- <bean id="AddConferenceController5"
class="org.yacos.web.chairman.controller.AddConferenceController"> class="org.yacos.web.chairman.controller.AddConferenceController">
<dwr:remote javascript="AddCriteriaJS" /> <dwr:remote javascript="AddCriteriaJS" />
<property name="sessionForm" value="true" /> <property name="sessionForm" value="true" />
@@ -174,16 +174,21 @@
value="org.yacos.web.chairman.form.FormConference" /> value="org.yacos.web.chairman.form.FormConference" />
<property name="conferenceManager" ref="conferenceManager" /> <property name="conferenceManager" ref="conferenceManager" />
<property name="userManager" ref="userManager" /> <property name="userManager" ref="userManager" />
</bean> </bean> -->
<bean id="AddConferenceController" <bean id="AddConferenceController"
class="org.yacos.web.chairman.controller.AddConferenceController"> class="org.yacos.web.chairman.controller.AddConferenceController">
<dwr:remote javascript="AddCriteriaJS" />
<property name="sessionForm" value="true" /> <property name="sessionForm" value="true" />
<property name="commandName" value="formConference" /> <property name="commandName" value="formConference" />
<property name="commandClass" <property name="commandClass"
value="org.yacos.web.chairman.form.FormConference" /> value="org.yacos.web.chairman.form.FormConference" />
<property name="conferenceManager" ref="conferenceManager" /> <property name="conferenceManager" ref="conferenceManager" />
<property name="userManager" ref="userManager" /> <property name="userManager" ref="userManager" />
<property name="validator" ref="ConferenceValidator"/>
</bean>
<bean id="ConferenceValidator" class="org.yacos.web.chairman.validation.ConferenceValidator">
</bean> </bean>
<bean id="EvaluationController" <bean id="EvaluationController"

View File

@@ -20,15 +20,16 @@ import org.yacos.core.conferences.IConferenceManager;
import org.yacos.core.users.IUserManager; import org.yacos.core.users.IUserManager;
import org.yacos.core.users.User; import org.yacos.core.users.User;
import org.yacos.web.chairman.form.FormConference; import org.yacos.web.chairman.form.FormConference;
import org.yacos.web.chairman.validation.ConferenceValidator;
// TODO : Clean this class //TODO : Clean this class
public class AddConferenceController extends AbstractWizardFormController { public class AddConferenceController extends AbstractWizardFormController {
protected final Log logger = LogFactory.getLog(getClass()); protected final Log logger = LogFactory.getLog(getClass());
private IConferenceManager conferenceManager; private IConferenceManager conferenceManager;
private IUserManager userManager; private IUserManager userManager;
public IUserManager getUserManager() { public IUserManager getUserManager() {
@@ -43,71 +44,109 @@ public class AddConferenceController extends AbstractWizardFormController {
public void setConferenceManager(IConferenceManager conferenceManager) { public void setConferenceManager(IConferenceManager conferenceManager) {
this.conferenceManager = conferenceManager; this.conferenceManager = conferenceManager;
} }
// ########################################################### // ###########################################################
private static int nextPerson = 1; private static int nextPerson = 1;
private List<PersonBean> listPersonBean; private List<PersonBean> listPersonBean;
private List<PersonBean> listPersonFiltered;
private List<PersonBean> listPersonAdded; private List<PersonBean> listPersonAdded;
public void initPerson() { public void initPerson() {
listPersonBean = new ArrayList<PersonBean>(); listPersonBean = new ArrayList<PersonBean>();
listPersonAdded = new ArrayList<PersonBean>(); listPersonAdded = new ArrayList<PersonBean>();
listPersonFiltered = new ArrayList<PersonBean>();
List<User> listUsers = userManager.getUsers(); List<User> listUsers = userManager.getUsers();
for (Iterator i = listUsers.iterator(); i.hasNext();) { for (Iterator i = listUsers.iterator(); i.hasNext();) {
User user = (User) i.next(); User user = (User) i.next();
PersonBean pb = new PersonBean(); PersonBean pb = new PersonBean();
pb.setId(getNextPerson()); pb.setId(getNextPerson());
pb.setName(user.getFirstName()); pb.setName(user.getFirstName());
// TODO : voir login FIX (because, we need the login to tie the user with the conf) pb.setLogin(user.getLogin());
listPersonBean.add(pb); listPersonBean.add(pb);
} }
} }
public void fillUser(String text) {
if (text.equals(""))
listPersonFiltered = new ArrayList<PersonBean>();
else {
listPersonFiltered = new ArrayList<PersonBean>();
for (Iterator i = listPersonBean.iterator(); i.hasNext();) {
PersonBean b = (PersonBean) i.next();
if (b.getName().toLowerCase().contains(text.toLowerCase()))
listPersonFiltered.add(b);
}
}
}
public void setPerson(PersonBean b) { public void setPerson(PersonBean b) {
if (b.getId() == -1) { if (b.getId() == -1) {
b.setId(getNextPerson()); b.setId(getNextPerson());
} }
//listPersonAdded.remove(b); PersonBean truePerson = getTruePerson(b.getLogin());
listPersonAdded.add(b);
listPersonBean.remove(b); listPersonAdded.remove(truePerson);
listPersonAdded.add(truePerson);
listPersonBean.remove(truePerson);
listPersonFiltered.remove(truePerson);
} }
public void deletePerson(PersonBean b) { public void deletePerson(PersonBean b) {
listPersonAdded.remove(b);
listPersonBean.add(b); PersonBean truePerson = getTruePerson(b.getLogin());
// FIXME b different du b d'avant (dans le set...) listPersonAdded.remove(truePerson);
listPersonBean.add(truePerson);
} }
public PersonBean getTruePerson(String login) {
for (Iterator i = listPersonBean.iterator(); i.hasNext();) {
PersonBean b = (PersonBean) i.next();
if (b.getLogin().equals(login))
return b;
}
for (Iterator i = listPersonAdded.iterator(); i.hasNext();) {
PersonBean b = (PersonBean) i.next();
if (b.getLogin().equals(login))
return b;
}
return null;
}
private static synchronized int getNextPerson() private static synchronized int getNextPerson()
{ {
return nextPerson++; return nextPerson++;
} }
public List<PersonBean> getUsersFiltered() {
return listPersonFiltered;
}
public List<PersonBean> getUsers() { public List<PersonBean> getUsers() {
return listPersonBean; return listPersonBean;
} }
public List<PersonBean> getUsersAdded() { public List<PersonBean> getUsersAdded() {
return listPersonAdded; return listPersonAdded;
} }
// ########################################################### // ###########################################################
private static int nextId = 1; private static int nextId = 1;
private Set criteria = new HashSet(); private Set criteria = new HashSet();;
public Set getAllCriteria() { public Set getAllCriteria() {
return criteria; return criteria;
@@ -127,34 +166,20 @@ public class AddConferenceController extends AbstractWizardFormController {
} }
private static synchronized int getNextId() private static synchronized int getNextId()
{ {
return nextId++; return nextId++;
} }
// ########################################################### // ###########################################################
public AddConferenceController() { public AddConferenceController() {
setCommandName("formConference"); setCommandName("formConference");
setPages(new String[] {"addConference", "addConference2", "addConference3", "addConference4", "addConference5"}); setPages(new String[] {"addConference", "addConference2", "addConference3", "addConference4", "addConference5"});
} }
protected Object formBackingObject(HttpServletRequest request) throws ModelAndViewDefiningException { protected Object formBackingObject(HttpServletRequest request) throws ModelAndViewDefiningException {
logger.info("je passe ici"); FormConference conference = new FormConference();
FormConference conference = (FormConference)request.getSession().getAttribute("conferenceForm");
if (conference==null) {
conference = new FormConference();
logger.info("je passe ici la 1ère fois");
request.getSession().setAttribute("conferenceForm", conference);
}
return conference; return conference;
} }
@@ -165,48 +190,26 @@ public class AddConferenceController extends AbstractWizardFormController {
}*/ }*/
} }
protected Map referenceData(HttpServletRequest request, int page) {
/*if (page == 0) {
List creditCardTypes = new ArrayList();
creditCardTypes.add("Visa");
creditCardTypes.add("MasterCard");
creditCardTypes.add("American Express");
Map model = new HashMap();
model.put("creditCardTypes", creditCardTypes);
return model;
}*/
return null;
}
/*protected int getTargetPage(HttpServletRequest request, Object command, Errors errors, int currentPage) {
FormConference conference = (FormConference) command;
if (currentPage == 0) {
return 1;
}
else {
return 2;
}
}*/
protected void validatePage(Object command, Errors errors, int page) { protected void validatePage(Object command, Errors errors, int page) {
FormConference conference = (FormConference) command; FormConference conference = (FormConference) command;
/*OrderValidator orderValidator = (OrderValidator) getValidator(); ConferenceValidator conferenceValidator = (ConferenceValidator) getValidator();
errors.setNestedPath("order");
switch (page) { switch (page) {
case 0: case 0:
orderValidator.validateCreditCard(orderForm.getOrder(), errors); conferenceValidator.validateFirstPage(conference, errors);
orderValidator.validateBillingAddress(orderForm.getOrder(), errors); break;
break; case 1:
case 1: conferenceValidator.validateSecondPage(conference, errors);
orderValidator.validateShippingAddress(orderForm.getOrder(), errors); break;
case 2:
conferenceValidator.validateThirdPage(conference, errors);
break;
} }
errors.setNestedPath("");*/
} }
protected ModelAndView processFinish( protected ModelAndView processFinish(
HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) { HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) {
FormConference conference = (FormConference) command; FormConference conference = (FormConference) command;
/*this.petStore.insertOrder(orderForm.getOrder()); /*this.petStore.insertOrder(orderForm.getOrder());
request.getSession().removeAttribute("sessionCart"); request.getSession().removeAttribute("sessionCart");
Map model = new HashMap(); Map model = new HashMap();

View File

@@ -4,7 +4,16 @@ public class PersonBean {
private int id; private int id;
private String name; private String name;
private String login;
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public PersonBean() {} public PersonBean() {}
public String getName() { public String getName() {

View File

@@ -1,20 +1,20 @@
package org.yacos.web.chairman.form; package org.yacos.web.chairman.form;
import java.util.Date;
public class FormConference { public class FormConference {
private Integer id; private Integer id;
private String title; private String title;
private String description; private String description;
private String otherInformations; private String otherInformations;
private Date dateAbstract;
private Date dateArticle;
private Date dateEvaluation;
private Date dateStart;
private Date dateEnd;
private String typeAction; private String dateArticle;
private String dateEvaluation;
private String dateStart;
private String dateEnd;
private int pageNumber;
private String fileType;
private String sendInfo;
public FormConference () {} public FormConference () {}
@@ -50,54 +50,59 @@ public class FormConference {
this.otherInformations = otherInformations; this.otherInformations = otherInformations;
} }
public Date getDateAbstract() { public int getPageNumber() {
return dateAbstract; return pageNumber;
} }
public void setDateAbstract(Date dateAbstract) { public void setPageNumber(int pageNumber) {
this.dateAbstract = dateAbstract; this.pageNumber = pageNumber;
} }
public Date getDateArticle() { public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getSendInfo() {
return sendInfo;
}
public void setSendInfo(String sendInfo) {
this.sendInfo = sendInfo;
}
public String getDateArticle() {
return dateArticle; return dateArticle;
} }
public void setDateArticle(Date dateArticle) { public void setDateArticle(String dateArticle) {
this.dateArticle = dateArticle; this.dateArticle = dateArticle;
} }
public Date getDateEvaluation() { public String getDateEvaluation() {
return dateEvaluation; return dateEvaluation;
} }
public void setDateEvaluation(Date dateEvaluation) { public void setDateEvaluation(String dateEvaluation) {
this.dateEvaluation = dateEvaluation; this.dateEvaluation = dateEvaluation;
} }
public Date getDateStart() { public String getDateStart() {
return dateStart; return dateStart;
} }
public void setDateStart(Date dateStart) { public void setDateStart(String dateStart) {
this.dateStart = dateStart; this.dateStart = dateStart;
} }
public Date getDateEnd() { public String getDateEnd() {
return dateEnd; return dateEnd;
} }
public void setDateEnd(Date dateEnd) { public void setDateEnd(String dateEnd) {
this.dateEnd = dateEnd; this.dateEnd = dateEnd;
} }
public String getTypeAction() {
return typeAction;
}
public void setTypeAction(String typeAction) {
this.typeAction = typeAction;
}
} }

View File

@@ -0,0 +1,36 @@
package org.yacos.web.chairman.validation;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import org.yacos.web.chairman.form.FormConference;
public class ConferenceValidator implements Validator {
public boolean supports(Class commandClass) {
return FormConference.class.isAssignableFrom(commandClass);
}
public void validate(Object obj, Errors errors) {
validateFirstPage((FormConference) obj, errors);
validateSecondPage((FormConference) obj, errors);
validateThirdPage((FormConference) obj, errors);
}
public void validateFirstPage(FormConference conference, Errors errors) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", "TITLE_REQUIRED", "A title is required");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "DESCRIPTION_REQUIRED", "A description is required");
}
public void validateSecondPage(FormConference conference, Errors errors) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dateStart", "DATE_REQUIRED", "A date is required");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dateEnd", "DATE_REQUIRED", "A date is required");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dateArticle", "DATE_REQUIRED", "A date is required");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dateEvaluation", "DATE_REQUIRED", "A date is required");
}
public void validateThirdPage(FormConference conference, Errors errors) {
}
}