[Submit] il y a rien qui est envoyé
j'essaye d'envoyer les donnée mais il y a rien qui se passe
voila ma jsp qui enregistre ou modifie
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| <%@ page language="java" pageEncoding="ISO-8859-1" contentType="text/html;charset=ISO-8859-1"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/spring.tld" prefix="spring" %>
<%@ page isELIgnored="false" %>
<html>
<head>
<title>Spring-mvc : Personnes</title>
</head>
<body background="../ressources/standard.jpg">
<h2>Ajout/Modification d'une personne</h2>
<spring:bind path="personne">
<c:if test="${status.error}">
<h3>Les erreurs suivantes se sont produites :</h3>
<ul>
<c:forEach items="${status.errorMessages}" var="erreur">
<li><c:out value="${erreur}"/></li>
</c:forEach>
</ul>
<hr>
</c:if>
</spring:bind>
<form method="post" action="<c:url value="/edit.html"/>">
<table border="1">
<tr>
<td>Id</td>
<td>${personne.id}</td>
</tr>
<tr>
<td>Version</td>
<spring:bind path="personne.version">
<td>
<input type="text" value="${status.value}" name="${status.expression}" size="20">
</td>
<td>${status.errorMessage}</td>
</spring:bind>
</tr>
<tr>
<td>Prénom</td>
<spring:bind path="personne.prenom">
<td>
<input type="text" value="${status.value}" name="${status.expression}" size="20">
</td>
<td>${status.errorMessage}</td>
</spring:bind>
</tr>
<tr>
<td>Nom</td>
<spring:bind path="personne.nom">
<td>
<input type="text" value="${status.value}" name="${status.expression}" size="20">
</td>
<td>${status.errorMessage}</td>
</spring:bind>
</tr>
<tr>
<td>Date de naissance (JJ/MM/AAAA)</td>
<spring:bind path="personne.datenaissance">
<td>
<input type="text" value="${status.value}" name="${status.expression}">
</td>
<td>${status.errorMessage}</td>
</spring:bind>
</tr>
<tr>
<td>Marié</td>
<td>
<c:choose>
<c:when test="${personne.marie==1}">
<input type="radio" name="marie" value="true" checked>Oui
<input type="radio" name="marie" value="false">Non
</c:when>
<c:when test="${personne.marie==0}">
<input type="radio" name="marie" value="true">Oui
<input type="radio" name="marie" value="false" checked>Non
</c:when>
<c:otherwise>
<input type="radio" name="marie" value="true">Oui
<input type="radio" name="marie" value="false" checked>Non
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td>Nombre d'enfants</td>
<spring:bind path="personne.nbenfants">
<td>
<input type="text" value="${status.value}" name="${status.expression}">
</td>
<td>${status.errorMessage}</td>
</spring:bind>
</tr>
</table>
<br>
<input type="hidden" value="${personne.id}" name="id">
<input type="submit" value="Valider">
<a href="<c:url value="/list.html"/>">Annuler</a>
</form>
</body>
</html> |
et ma classe DAO qui fait les appels a hibernate est la suivante
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
| package istia.st.springmvc.personnes.dao;
//import istia.st.springmvc.personnes.entites.Personne;
import istia.st.springmvc.personnes.hibernate.HibernateUtil;
import istia.st.springmvc.personnes.hibernate.Personnes;
import istia.st.springmvc.personnes.utils.SpringUtils;
import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
//import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
public class DaoImplCommon extends HibernateDaoSupport implements
IDao {
// configuration: parametres + mapping
public Configuration config = null;
// Usine à fabriquer des sessions
public SessionFactory factory = null;
// liste des personnes
public List getAll() {
return getHibernateTemplate().find(
"from Personnes ");
}
// obtenir une personne en particulier
public Personnes getOne(int id) {
// on la récupère dans la BD
try
{
if ((Integer)id != null)
{
List r = getHibernateTemplate().find(
"from Personnes where id = "+id);
if (r.size() == 0)
{
return null;
}
else
{
return (Personnes) r.get(0);
}
}
return null;
}
catch (HibernateObjectRetrievalFailureException e)
{
return null;
}
}
// suppression d'une personne
public void deleteOne(int id) {
// on supprime la personne
/*int n = getSqlMapClientTemplate().delete("Personne.deleteOne",
new Integer(id));
// a-t-on réussi
if (n == 0) {
throw new DaoException("Personne d'id [" + id + "] inconnue", 2);
}*/
}
// ajouter ou modifier une personne
public void saveOne(Personnes personne) {
// le paramètre personne est-il valide ?
check(personne);
// ajout ou modification ?
if (personne.getId() == -1) {
// ajout
insertPersonne(personne);
} else {
updatePersonne(personne);
}
}
// ajouter une personne
protected void insertPersonne(Personnes personne) {
// 1ère version
personne.setVersion(1);
getHibernateTemplate().save(personne);
}
// modifier une personne
protected void updatePersonne(Personnes personne) {
// on attend 10 ms - pour les tests mettre true au lieu de false
getHibernateTemplate().update(personne);
}
// vérification validité d'une personne
private void check(Personnes p) {
// personne p
if (p == null) {
throw new DaoException("Personne null", 10);
}
// id
if (p.getId() != -1 && p.getId() < 0) {
throw new DaoException("Id [" + p.getId() + "] invalide", 11);
}
// date de naissance
if (p.getDatenaissance() == null) {
throw new DaoException("Date de naissance manquante", 12);
}
// nombre d'enfants
if (p.getNbenfants() < 0) {
throw new DaoException("Nombre d'enfants [" + p.getNbenfants()
+ "] invalide", 13);
}
// nom
if (p.getNom() == null || p.getNom().trim().length() == 0) {
throw new DaoException("Nom manquant", 14);
}
// prénom
if (p.getPrenom() == null || p.getPrenom().trim().length() == 0) {
throw new DaoException("Prénom manquant", 15);
}
}
// attente
private void wait(int N) {
// on attend N ms
try {
Thread.sleep(N);
} catch (InterruptedException e) {
// on affiche la trace de l'exception
e.printStackTrace();
return;
}
}
} |
est ce que quelqu'un aurait une idee du probleme que j'ai ?
merci