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'>
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() {
fillTable();
}
@@ -33,22 +25,26 @@ function fillTable() {
}});
// Create a new set cloned from the pattern row
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++) {
person = criteria[i];
id = person.id;
dwr.util.cloneNode("pattern", { idSuffix:id });
dwr.util.setValue("tableCriterion" + id, person.label);
dwr.util.setValue("tableCriterionMin" + id, person.min);
dwr.util.setValue("tableCriterionMax" + id, person.max);
$("pattern" + id).style.display = "table-row";
dwr.util.setValue("tableCriterionMax" + id, person.max);
$("tableCriterion").style.display = "";
$("pattern" + id).style.display = "";
peopleCache[id] = person;
}
});
}
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)];
dwr.util.setValues(person);
}
@@ -58,8 +54,7 @@ function deleteClicked(eleid) {
var person = peopleCache[eleid.substring(6)];
if (confirm("Are you sure you want to delete " + person.label + "?")) {
dwr.engine.beginBatch();
AddCriteriaJS.deleteCriterion(person);
// FIXME here
AddCriteriaJS.deleteCriterion(person);
fillTable();
dwr.engine.endBatch();
}
@@ -90,43 +85,31 @@ function clearPerson() {
<form:form commandName="formConference" name="monForm">
<fieldset><legend>Criteria</legend> Label : <input
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>
<fieldset style="border-width: 1px;"><legend>Criteria</legend>
<table class="plain">
<tr>
<td>Label:</td>
<td><input id="label" type="text" size="30" /></td>
<td><input id="label" type="text"/></td>
</tr>
<tr>
<td>Min:</td>
<td><input id="min" type="text" size="20" /></td>
<td><input id="min" type="text"/></td>
</tr>
<tr>
<td>Max:</td>
<td><input id="max" type="text" size="40" /></td>
<td><input id="max" type="text"/></td>
</tr>
<tr>
<td colspan="2" align="right"><small>(ID=<span id="id">-1</span>)</small>
<input type="button" value="Save" onclick="writePerson()" /> <input
type="button" value="Clear" onclick="clearPerson()" /></td>
<a href="<c:url value="Javascript:writePerson();"/>" >Save</a>
<a href="<c:url value="Javascript:clearPerson();"/>" >Clear</a>
</td>
</tr>
</table>
<table border="1">
<br />
<table border="1" id="tableCriterion" style="display: none;">
<thead>
<tr>
<th>Criterion</th>
@@ -140,14 +123,14 @@ 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>
<td>
<input id="edit" type="button" value="Edit" onclick="editClicked(this.id)" />
<input id="delete" type="button" value="Delete" onclick="deleteClicked(this.id)" />
</td>
</tr>
</tbody>
</table>
<br />
<br />
<input type="submit" align="middle" name="_target2" value="Back">
@@ -155,6 +138,7 @@ function clearPerson() {
</form:form>
<br />
<br />
<a href="<c:url value="main.htm"/>">Home</a>

View File

@@ -1,6 +1,5 @@
<%@ include file="/WEB-INF/decorators/include.jsp"%>
<%@ page import="org.acegisecurity.context.SecurityContextHolder" %>
<%@page import="org.acegisecurity.context.SecurityContextHolder"%>
<html>
<head></head>
<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++;
}
}