Ajax pour l'ajout des utilisateurs
Policy failures: Code warning - failed on resource AddConferenceController.java. Reason: HashSet is a raw type. References to generic type HashSet<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 61 - failed on resource AddConferenceController.java. Reason: Map is a raw type. References to generic type Map<K,V> should be parameterized, line 166 - failed on resource addConference4.jsp. Reason: No end tag (</fieldset>)., line 148 - failed on resource AddConferenceController.java. Reason: Set is a raw type. References to generic type Set<E> should be parameterized, line 108 ... and more. Override reason: hehe
This commit is contained in:
@@ -43,8 +43,7 @@ function fillTable() {
|
||||
}
|
||||
|
||||
function editClicked(eleid) {
|
||||
// we were an id of the form "edit{id}", eg "edit42". We lookup the "42"
|
||||
alert(eleid);
|
||||
// we were an id of the form "edit{id}", eg "edit42". We lookup the "42"
|
||||
var person = peopleCache[eleid.substring(4)];
|
||||
dwr.util.setValues(person);
|
||||
}
|
||||
@@ -75,6 +74,15 @@ function clearPerson() {
|
||||
dwr.util.setValues({ id:-1, label:null, min:null, max:null });
|
||||
}
|
||||
|
||||
function submitIfNotEnter(theForm){
|
||||
if(theForm.elements["submit"] || theForm.elements["submit"]){
|
||||
return true;
|
||||
} else {
|
||||
writePerson();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
@@ -83,9 +91,9 @@ function clearPerson() {
|
||||
|
||||
<h2 align="center"><fmt:message key="conference.titleMenu" /></h2>
|
||||
|
||||
<form:form commandName="formConference" name="monForm">
|
||||
<form:form commandName="formConference" name="monForm" onsubmit="return submitIfNotEnter(this)">
|
||||
|
||||
<fieldset style="border-width: 1px;"><legend>Criteria</legend>
|
||||
<fieldset><legend>Criteria</legend>
|
||||
<table class="plain">
|
||||
<tr>
|
||||
<td>Label:</td>
|
||||
@@ -101,8 +109,8 @@ function clearPerson() {
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right"><small>(ID=<span id="id">-1</span>)</small>
|
||||
<a href="<c:url value="Javascript:writePerson();"/>" >Save</a>
|
||||
<a href="<c:url value="Javascript:clearPerson();"/>" >Clear</a>
|
||||
<a href="#" onclick="writePerson()">Save</a>
|
||||
<a href="#" onclick="clearPerson()">Clear</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -123,9 +131,9 @@ function clearPerson() {
|
||||
<td><span id="tableCriterion">Criterion</span></td>
|
||||
<td><span id="tableCriterionMin">Min</span></td>
|
||||
<td><span id="tableCriterionMax">Max</span></td>
|
||||
<td>
|
||||
<input id="edit" type="button" value="Edit" onclick="editClicked(this.id)" />
|
||||
<input id="delete" type="button" value="Delete" onclick="deleteClicked(this.id)" />
|
||||
<td>
|
||||
<a id="edit" href="#" onclick="editClicked(this.id)" >Edit</a>
|
||||
<a id="delete" href="#" onclick="deleteClicked(this.id)" >Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -133,11 +141,17 @@ function clearPerson() {
|
||||
|
||||
<br />
|
||||
|
||||
<input type="submit" align="middle" name="_target2" value="Back">
|
||||
<input type="submit" align="middle" name="_target4" value="Next" />
|
||||
<input type="submit" align="middle" name="_target2" value="Back" onclick="this.form.elements['submit']=true">
|
||||
<input type="submit" align="middle" name="_target4" value="Next" onclick="this.form.elements['submit']=true" />
|
||||
|
||||
|
||||
</form:form>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
init();
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<a href="<c:url value="main.htm"/>">Home</a>
|
||||
|
||||
@@ -1,7 +1,114 @@
|
||||
<%@ include file="/WEB-INF/decorators/include.jsp"%>
|
||||
|
||||
<html>
|
||||
<head></head>
|
||||
<head>
|
||||
|
||||
<script type='text/javascript' src='./dwr/engine.js'></script>
|
||||
<script type='text/javascript' src='./dwr/util.js'></script>
|
||||
<script type='text/javascript' src='./dwr/interface/AddCriteriaJS.js'></script>
|
||||
<script type='text/javascript' src='./javascripts/prototype.js'></script>
|
||||
|
||||
<script type='text/javascript'>
|
||||
|
||||
function init() {
|
||||
dwr.engine.setAsync(false); // a v<>rifier
|
||||
AddCriteriaJS.initPerson();
|
||||
dwr.engine.setAsync(true);
|
||||
setTimeout("fillTable()", 500);
|
||||
}
|
||||
|
||||
var peopleCache = { };
|
||||
var peopleCache2 = { };
|
||||
var viewed = -1;
|
||||
|
||||
function fillTable() {
|
||||
AddCriteriaJS.getUsers(function(people) {
|
||||
// Delete all the rows except for the "pattern" row
|
||||
dwr.util.removeAllRows("personbody", { filter:function(tr) {
|
||||
return (tr.id != "pattern");
|
||||
}});
|
||||
// Create a new set cloned from the pattern row
|
||||
var person, id;
|
||||
people.sort(function(p1, p2) { return p1.name.localeCompare(p2.name); });
|
||||
|
||||
for (var i = 0; i < people.length; i++) {
|
||||
person = people[i];
|
||||
id = person.id;
|
||||
dwr.util.cloneNode("pattern", { idSuffix:id });
|
||||
dwr.util.setValue("tablePerson" + id, person.name);
|
||||
$("pattern" + id).style.display = "";
|
||||
peopleCache[id] = person;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function fillTable2() {
|
||||
AddCriteriaJS.getUsersAdded(function(people) {
|
||||
// Delete all the rows except for the "pattern" row
|
||||
dwr.util.removeAllRows("personbodyadded", { filter:function(tr) {
|
||||
return (tr.id != "patternadded");
|
||||
}});
|
||||
// Create a new set cloned from the pattern row
|
||||
var person, id;
|
||||
people.sort(function(p1, p2) { return p1.name.localeCompare(p2.name); });
|
||||
|
||||
for (var i = 0; i < people.length; i++) {
|
||||
person = people[i];
|
||||
id = person.id;
|
||||
dwr.util.cloneNode("patternadded", { idSuffix:id });
|
||||
dwr.util.setValue("tablePersonadded" + id, person.name);
|
||||
$("patternadded" + id).style.display = "";
|
||||
peopleCache2[id] = person;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addPerson(eleid) {
|
||||
var person = peopleCache[eleid.substring(6)];
|
||||
/*dwr.util.cloneNode("patternadded", { idSuffix:person.id });
|
||||
dwr.util.setValue("tablePersonadded" + person.id, person.name);
|
||||
$("patternadded" + person.id).style.display = "";
|
||||
peopleCache[person.id] = person;*/
|
||||
|
||||
dwr.engine.beginBatch();
|
||||
AddCriteriaJS.setPerson(person);
|
||||
fillTable2();
|
||||
dwr.engine.endBatch();
|
||||
}
|
||||
|
||||
function deletePerson(eleid) {
|
||||
// we were an id of the form "delete{id}", eg "delete42". We lookup the "42"
|
||||
var person = peopleCache2[eleid.substring(11)];
|
||||
if (confirm("Are you sure you want to delete " + person.name + "?")) {
|
||||
dwr.engine.beginBatch();
|
||||
AddCriteriaJS.deletePerson(person);
|
||||
fillTable2();
|
||||
dwr.engine.endBatch();
|
||||
}
|
||||
}
|
||||
|
||||
function writePerson() {
|
||||
var person = { id:viewed, label:null, min:null, max:null };
|
||||
dwr.util.getValues(person);
|
||||
|
||||
dwr.engine.beginBatch();
|
||||
AddCriteriaJS.setPerson(person);
|
||||
fillTable();
|
||||
dwr.engine.endBatch();
|
||||
}
|
||||
|
||||
function clearPerson() {
|
||||
viewed = -1;
|
||||
dwr.util.setValues({ id:-1, label:null, min:null, max:null });
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@@ -9,13 +116,47 @@
|
||||
|
||||
<form:form commandName="formConference" name="monForm">
|
||||
|
||||
<br /> Page 5
|
||||
<table border="1">
|
||||
<tr align="right">
|
||||
<td></td>
|
||||
<td>Filter <input id="filter" type="text"/></td>
|
||||
</tr>
|
||||
<tbody id="personbody">
|
||||
<tr id="pattern" style="display: none;">
|
||||
<td><span id="tablePerson">Person</span></td>
|
||||
<td>
|
||||
<a id="addNew" href="#" onclick="addPerson(this.id)" >Add</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<br />
|
||||
<table border="1">
|
||||
<tbody id="personbodyadded">
|
||||
<tr id="patternadded" style="display: none;">
|
||||
<td><span id="tablePersonadded">Person</span></td>
|
||||
<td>
|
||||
<a id="supprPerson" href="#" onclick="deletePerson(this.id)" >Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<input type="submit" align="middle" name="_finish" value="Next" />
|
||||
<input type="submit" align="middle" name="_target3" value="Back">
|
||||
<input type="submit" align="middle" name="_finish" value="Next" />
|
||||
|
||||
|
||||
</form:form>
|
||||
|
||||
<script type="text/javascript">
|
||||
init();
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<a href="<c:url value="main.htm"/>">Home</a>
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package org.yacos.web.chairman.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -13,6 +17,8 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.ModelAndViewDefiningException;
|
||||
import org.springframework.web.servlet.mvc.AbstractWizardFormController;
|
||||
import org.yacos.core.conferences.IConferenceManager;
|
||||
import org.yacos.core.users.IUserManager;
|
||||
import org.yacos.core.users.User;
|
||||
import org.yacos.web.chairman.form.FormConference;
|
||||
|
||||
|
||||
@@ -22,7 +28,15 @@ public class AddConferenceController extends AbstractWizardFormController {
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private IConferenceManager conferenceManager;
|
||||
|
||||
private IUserManager usersManager;
|
||||
|
||||
public IUserManager getUsersManager() {
|
||||
return usersManager;
|
||||
}
|
||||
public void setUsersManager(IUserManager usersManager) {
|
||||
this.usersManager = usersManager;
|
||||
}
|
||||
public IConferenceManager getConferenceManager() {
|
||||
return conferenceManager;
|
||||
}
|
||||
@@ -31,6 +45,58 @@ public class AddConferenceController extends AbstractWizardFormController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ###########################################################
|
||||
|
||||
private static int nextPerson = 1;
|
||||
|
||||
private List<PersonBean> listPersonBean;
|
||||
private List<PersonBean> listPersonAdded;
|
||||
|
||||
public void initPerson() {
|
||||
listPersonBean = new ArrayList<PersonBean>();
|
||||
listPersonAdded = new ArrayList<PersonBean>();
|
||||
List<User> listUsers = usersManager.getUsers();
|
||||
for (Iterator i = listUsers.iterator(); i.hasNext();) {
|
||||
User user = (User) i.next();
|
||||
|
||||
PersonBean pb = new PersonBean();
|
||||
pb.setId(getNextPerson());
|
||||
pb.setName(user.getFirstName());
|
||||
// TODO : voir login FIX (because, we need the login to tie the user with the conf)
|
||||
listPersonBean.add(pb);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPerson(PersonBean b) {
|
||||
if (b.getId() == -1) {
|
||||
b.setId(getNextPerson());
|
||||
}
|
||||
|
||||
listPersonAdded.remove(b);
|
||||
listPersonAdded.add(b);
|
||||
}
|
||||
|
||||
public void deletePerson(PersonBean b) {
|
||||
listPersonAdded.remove(b);
|
||||
}
|
||||
|
||||
private static synchronized int getNextPerson()
|
||||
{
|
||||
return nextPerson++;
|
||||
}
|
||||
|
||||
public List<PersonBean> getUsers() {
|
||||
return listPersonBean;
|
||||
}
|
||||
|
||||
public List<PersonBean> getUsersAdded() {
|
||||
return listPersonAdded;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ###########################################################
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.yacos.web.chairman.controller;
|
||||
|
||||
public class PersonBean {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
|
||||
public PersonBean() {}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user