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:
Frederic Debuire
2008-01-28 16:53:14 +00:00
parent 43b339247c
commit 8b0757c4ec
4 changed files with 261 additions and 14 deletions

View File

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

View File

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