Ajax suite

This commit is contained in:
Frederic Debuire
2008-01-27 21:23:54 +00:00
parent 41f2c4d54a
commit 88e40466ac
3 changed files with 26 additions and 78 deletions

View File

@@ -10,14 +10,6 @@
<script type='text/javascript'> <script type='text/javascript'>
function addCriteria() {
var criteria = new Array();
var myString = "" + $F("monForm.labelCriteria") + " - Notation : Between " + $F("monForm.minCriteria") + " and " + $F("monForm.maxCriteria");
criteria.push(myString);
dwr.util.addOptions("listCriteria", criteria);
$("divCriteria").style.display = "";
}
function init() { function init() {
fillTable(); fillTable();
} }
@@ -34,6 +26,8 @@ function fillTable() {
// Create a new set cloned from the pattern row // Create a new set cloned from the pattern row
var person, id; var person, id;
criteria.sort(function(p1, p2) { return p1.label.localeCompare(p2.label); }); criteria.sort(function(p1, p2) { return p1.label.localeCompare(p2.label); });
if (criteria.length == 0)
$("tableCriterion").style.display = "none";
for (var i = 0; i < criteria.length; i++) { for (var i = 0; i < criteria.length; i++) {
person = criteria[i]; person = criteria[i];
id = person.id; id = person.id;
@@ -41,7 +35,8 @@ function fillTable() {
dwr.util.setValue("tableCriterion" + id, person.label); dwr.util.setValue("tableCriterion" + id, person.label);
dwr.util.setValue("tableCriterionMin" + id, person.min); dwr.util.setValue("tableCriterionMin" + id, person.min);
dwr.util.setValue("tableCriterionMax" + id, person.max); dwr.util.setValue("tableCriterionMax" + id, person.max);
$("pattern" + id).style.display = "table-row"; $("tableCriterion").style.display = "";
$("pattern" + id).style.display = "";
peopleCache[id] = person; peopleCache[id] = person;
} }
}); });
@@ -49,6 +44,7 @@ function fillTable() {
function editClicked(eleid) { function editClicked(eleid) {
// we were an id of the form "edit{id}", eg "edit42". We lookup the "42" // we were an id of the form "edit{id}", eg "edit42". We lookup the "42"
alert(eleid);
var person = peopleCache[eleid.substring(4)]; var person = peopleCache[eleid.substring(4)];
dwr.util.setValues(person); dwr.util.setValues(person);
} }
@@ -59,7 +55,6 @@ function deleteClicked(eleid) {
if (confirm("Are you sure you want to delete " + person.label + "?")) { if (confirm("Are you sure you want to delete " + person.label + "?")) {
dwr.engine.beginBatch(); dwr.engine.beginBatch();
AddCriteriaJS.deleteCriterion(person); AddCriteriaJS.deleteCriterion(person);
// FIXME here
fillTable(); fillTable();
dwr.engine.endBatch(); dwr.engine.endBatch();
} }
@@ -90,43 +85,31 @@ function clearPerson() {
<form:form commandName="formConference" name="monForm"> <form:form commandName="formConference" name="monForm">
<fieldset><legend>Criteria</legend> Label : <input <fieldset style="border-width: 1px;"><legend>Criteria</legend>
id="monForm.labelCriteria" name="labelCriteria" type="text"> <br />
<br />
Notation : Between <input id="monForm.minCriteria" name="minCriteria"
type="text"> and <input id="monForm.maxCriteria"
name="maxCriteria" type="text"></fieldset>
<br />
<input type="button" value="Add criteria" onclick="addCriteria()">
<!--<div id="divCriteria" style="display:none;">
<ul id="listCriteria">
</ul>
</div>-->
<h3>Edit Person</h3>
<table class="plain"> <table class="plain">
<tr> <tr>
<td>Label:</td> <td>Label:</td>
<td><input id="label" type="text" size="30" /></td> <td><input id="label" type="text"/></td>
</tr> </tr>
<tr> <tr>
<td>Min:</td> <td>Min:</td>
<td><input id="min" type="text" size="20" /></td> <td><input id="min" type="text"/></td>
</tr> </tr>
<tr> <tr>
<td>Max:</td> <td>Max:</td>
<td><input id="max" type="text" size="40" /></td> <td><input id="max" type="text"/></td>
</tr> </tr>
<tr> <tr>
<td colspan="2" align="right"><small>(ID=<span id="id">-1</span>)</small> <td colspan="2" align="right"><small>(ID=<span id="id">-1</span>)</small>
<input type="button" value="Save" onclick="writePerson()" /> <input <a href="<c:url value="Javascript:writePerson();"/>" >Save</a>
type="button" value="Clear" onclick="clearPerson()" /></td> <a href="<c:url value="Javascript:clearPerson();"/>" >Clear</a>
</td>
</tr> </tr>
</table> </table>
<table border="1">
<br />
<table border="1" id="tableCriterion" style="display: none;">
<thead> <thead>
<tr> <tr>
<th>Criterion</th> <th>Criterion</th>
@@ -140,14 +123,14 @@ function clearPerson() {
<td><span id="tableCriterion">Criterion</span></td> <td><span id="tableCriterion">Criterion</span></td>
<td><span id="tableCriterionMin">Min</span></td> <td><span id="tableCriterionMin">Min</span></td>
<td><span id="tableCriterionMax">Max</span></td> <td><span id="tableCriterionMax">Max</span></td>
<td><input id="edit" type="button" value="Edit" <td>
onclick="editClicked(this.id)" /> <input id="delete" type="button" <input id="edit" type="button" value="Edit" onclick="editClicked(this.id)" />
value="Delete" onclick="deleteClicked(this.id)" /></td> <input id="delete" type="button" value="Delete" onclick="deleteClicked(this.id)" />
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<br />
<br /> <br />
<input type="submit" align="middle" name="_target2" value="Back"> <input type="submit" align="middle" name="_target2" value="Back">
@@ -156,6 +139,7 @@ function clearPerson() {
</form:form> </form:form>
<br /> <br />
<br />
<a href="<c:url value="main.htm"/>">Home</a> <a href="<c:url value="main.htm"/>">Home</a>
</body> </body>

View File

@@ -1,6 +1,5 @@
<%@ include file="/WEB-INF/decorators/include.jsp"%> <%@ include file="/WEB-INF/decorators/include.jsp"%>
<%@ page import="org.acegisecurity.context.SecurityContextHolder" %> <%@page import="org.acegisecurity.context.SecurityContextHolder"%>
<html> <html>
<head></head> <head></head>
<body> <body>

View File

@@ -1,35 +0,0 @@
package org.yacos.web.chairman.controller;
import java.util.HashSet;
import java.util.Set;
public class Criterions {
private static int nextId = 1;
private Set criteria = new HashSet();
public Set getAllCriteria() {
return criteria;
}
public void setCriterion(CriterionBean c) {
if (c.getId() == -1) {
c.setId(getNextId());
}
criteria.remove(c);
criteria.add(c);
}
public void deleteCriterion(CriterionBean c) {
criteria.remove(c);
}
private static synchronized int getNextId()
{
return nextId++;
}
}