Forums Rue-Montgallet.com
Rue-Montgallet.comRue-Hardware.comRue-Occasion.comRue-DVD.comRue-Jeuxvideo.comRue-AudioVideo.comRue-Telephone.comForums
S'inscrire | S'identifier |
| Recherche avancée | Aide
 
 

Achat - Vente Divers : super-warrior, S26157 et 29 utilisateurs inconnus

 Mot :   Pseudo :  
 
Bas de page
Auteur
 Sujet :

pb formulaire jsp session

 
n°16500
itr
Profil : Jeune recrue
Posté le 10-05-2006 à 15:04:30  profilanswer
 

Bonjour,
 
j'ai un formulaire jsp qui passe par un javaBean pour vérifier que les champs sont correctement remplis et je récupère aussi les valeurs des champs ds mon javaBean. Tout se passe bien tant que je remplis les champs par contre si je les laisse vide et qu'auparavant j'avais rempli ces champs, il ne prend pas le champ vide mais garde en mémoire l'ancienne valeur.
 

Code :
  1. <HEAD>
  2. <TITLE> Admin</TITLE>
  3. </HEAD>
  4. <jsp:useBean id="creation" class="servlets.index.nouveaucomposant" scope="session"/>
  5. <html>
  6. <body>
  7. <HTML>
  8. <BODY>
  9. <H1> <A NAME="HAUT">Gestion des stocks</A> </H1>
  10. <hr>
  11. <table>
  12. <tr>
  13. <td>
  14. <br><A HREF="#IM1">COMPOSANT</A>
  15. </td>
  16. <td>
  17. <br><A HREF="#IM2">PCB</A>
  18. </td>
  19. <td>
  20. <br><A HREF="#IM3">PCB Testé</A>
  21. </td>
  22. <td>
  23. </tr>
  24. </table>
  25. <br>
  26. <H2>Composant</H2> <A NAME="IM1"></A><form method="post"  action="verifchamp.jsp">
  27. <br><h3>Créer un composant</h3></br>
  28. <%@ include file="page1.jsp" %>
  29. <table border="0">
  30. <tr>
  31. <td>
  32. CODEKLK
  33. </td>
  34. <td>
  35.   <input name="codeKLK" value="KLK<%=inc3%>" type="text"  size="20" maxlength="20">
  36.  </td>
  37. </tr>
  38. <tr>
  39. <td>
  40. Quantité
  41. </td>
  42. <td>
  43.   <input name="qte"  type="text"  size="20" maxlength="20">
  44.  
  45.  </td>
  46. </tr>
  47. <tr>
  48.  <td>
  49. Seuil d'alerte
  50. </td>
  51. <td>
  52.   <input name="alerte"  type="text"  size="20" maxlength="20">
  53.  </td>
  54. </tr>
  55. <tr>
  56.  <td>
  57. Indice
  58. </td>
  59. <td>
  60.   <input name="indice" type="text" value="<%=creation.getindice()%>" size="20" maxlength="20">
  61. </td>
  62. </tr>
  63. <tr>
  64.  <td>
  65. Rohs
  66. </td>
  67. <td>
  68.    <input name="rohs"  type="text" value="<%=creation.getrohs()%>" size="20" maxlength="30">
  69. </td>
  70. </tr>
  71. <tr>
  72.   <input type="submit" value="Envoyer">
  73.  
  74.   <input type="reset" value="Annuler">
  75. </form>


 
verif.jsp

Code :
  1. <jsp:useBean id="creation" class="servlets.index.nouveaucomposant" scope="session"/>
  2. <jsp:setProperty name="creation" property="*" />
  3. <%
  4.     creation.setErrors(); 
  5.     String next;
  6.     if (creation.getErrorQuantity()==0) {
  7.       // data is OK
  8.       // dispatch to thanks
  9.       next = "verifavantinsertion.jsp";
  10.     }
  11.     else {
  12.       // data has errors, try again
  13.       next = "composant.jsp";
  14.       creation.getErrors();
  15.       for (int i=0; i<creation.getErrorQuantity() ; i++) {
  16.       %><font color="red"><%=creation.PrintErrors(i)%></font><br><%
  17.        }}
  18.        %>
  19.      
  20. <jsp:include page="<%= next %>" />


 

n°16501
itr
Profil : Jeune recrue
Posté le 10-05-2006 à 15:15:17  profilanswer
 

pb résolu
 
<%String ind = request.getParameter("indice" );
<jsp:setProperty name="creation" property="indice"  value="<%=ind %>" />
 
j'ai rajouté ces 2 lignes à mon prog verif.jsp


Aller à :
Ajouter une réponse