merci pour ta collaboration :
je vais maintenant etre + clair :
J'ai une page JSP pour ajouter un nouveau client :
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
|
<%@ page language="java"%>
<%@ taglib uri='/WEB-INF/struts-bean.tld' prefix='bean'%>
<%@ taglib uri='/WEB-INF/struts-html.tld' prefix='html'%>
<%@ taglib uri='/WEB-INF/struts-logic.tld' prefix='logic'%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<title>Ajouter un Utilisateur</title>
</head>
<body>
<div id="body_wrapper">
<div id="body">
<div id="all">
<div class="top"></div>
<div class="content">
<html:form action="/clientAdd.do" method="POST">
<table border="0" align="center" width="50%" height="50%">
<tr>
<td>nom du Client : <td/>
<td><html:text property="nom"/><html:errors property="nom"/><br/><td/>
<tr/>
<tr>
<td>Adresse: <td/>
<td><html:text property="adresse"/><html:errors property="adresse"/><br/><td/>
<tr/>
<tr>
<td>Besoin : <td/>
<td><html:select property="besoin">
<html:option value="voix TDM">voix TDM</html:option>
<html:option value="voix sur IP">voix sur IP</html:option>
<html:option value="Internet">Internet</html:option>
<html:option value="Data">Data</html:option></html:select>
<html:errors property="fonction"/><br/><td/>
<tr/>
<tr>
<td>Contact nom : <td/>
<td><html:text property="contactnom"/><html:errors property="contactnom"/><br/><td/>
<tr/>
<tr>
<td>Contact numero : <td/>
<td><html:text property="contactnum"/><html:errors property="contactnum"/><br/><td/>
<tr/>
<tr>
<td colspan="1">
<html:submit>Save</html:submit>
</td>
</tr>
</table>
<input type="hidden" name="request_time" value="<%=System.currentTimeMillis()%>" />
</html:form>
</div>
<div class="bottom"></div>
</div>
</div>
</div><div id="end_body"></div>
</body>
</html> |
le bean et le form corresponsant :
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
|
package com.gestionclientmeditel.persistance;
public class ClientBean implements java.io.Serializable {
private String nom;
private String adresse;
private String latitude;
private String longitude;
private String hauteursite;
private String contactnom;
private String contactnum;
private String dateajout;
private String besoin;
private String capacite;
private int etape;
public ClientBean(String nom,String adresse ,String besoin,String contactnom,String contactnum,int etape)
{
super();
this.nom=nom;
this.adresse=adresse;
this.besoin=besoin;
this.contactnom=contactnom;
this.contactnum=contactnum;
this.etape=etape;
}
public ClientBean(){
super();
}
public int getEtape() {
return etape;
}
public void setEtape(int etape){
this.etape=etape;
}
public String getNom() {
return nom;
}
public void setNom(String nom){
this.nom=nom;
}
public String getAdresse() {
return adresse;
}
public void setAdresse(String adresse){
this.adresse=adresse;
}
public String getBesoin() {
return besoin;
}
public void setBesoin(String besoin){
this.besoin=besoin;
}
public String getContactnom() {
return contactnom;
}
public void setContactnom(String contactnom){
this.contactnom=contactnom;
}
public String getContactnum() {
return contactnum;
}
public void setContactnum(String contactnum){
this.contactnum=contactnum;
}
/**
* @return Returns the capacite.
*/
public String getCapacite() {
return capacite;
}
/**
* @param capacite The capacite to set.
*/
public void setCapacite(String capacite) {
this.capacite = capacite;
}
/**
* @return Returns the dateajout.
*/
public String getDateajout() {
return dateajout;
}
/**
* @param dateajout The dateajout to set.
*/
public void setDateajout(String dateajout) {
this.dateajout = dateajout;
}
/**
* @return Returns the hauteursite.
*/
public String getHauteursite() {
return hauteursite;
}
/**
* @param hauteursite The hauteursite to set.
*/
public void setHauteursite(String hauteursite) {
this.hauteursite = hauteursite;
}
/**
* @return Returns the latitude.
*/
public String getLatitude() {
return latitude;
}
/**
* @param latitude The latitude to set.
*/
public void setLatitude(String latitude) {
this.latitude = latitude;
}
/**
* @return Returns the longitude.
*/
public String getLongitude() {
return longitude;
}
/**
* @param longitude The longitude to set.
*/
public void setLongitude(String longitude) {
this.longitude = longitude;
}
} |
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
|
<%@ page language="java"%>
<%@ taglib uri='/WEB-INF/struts-bean.tld' prefix='bean'%>
<%@ taglib uri='/WEB-INF/struts-html.tld' prefix='html'%>
<%@ taglib uri='/WEB-INF/struts-logic.tld' prefix='logic'%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<title>Ajouter un Utilisateur</title>
</head>
<body>
<div id="body_wrapper">
<div id="body">
<div id="all">
<div class="top"></div>
<div class="content">
<html:form action="/clientAdd.do" method="POST">
<table border="0" align="center" width="50%" height="50%">
<tr>
<td>nom du Client : <td/>
<td><html:text property="nom"/><html:errors property="nom"/><br/><td/>
<tr/>
<tr>
<td>Adresse: <td/>
<td><html:text property="adresse"/><html:errors property="adresse"/><br/><td/>
<tr/>
<tr>
<td>Besoin : <td/>
<td><html:select property="besoin">
<html:option value="voix TDM">voix TDM</html:option>
<html:option value="voix sur IP">voix sur IP</html:option>
<html:option value="Internet">Internet</html:option>
<html:option value="Data">Data</html:option></html:select>
<html:errors property="fonction"/><br/><td/>
<tr/>
<tr>
<td>Contact nom : <td/>
<td><html:text property="contactnom"/><html:errors property="contactnom"/><br/><td/>
<tr/>
<tr>
<td>Contact numero : <td/>
<td><html:text property="contactnum"/><html:errors property="contactnum"/><br/><td/>
<tr/>
<tr>
<td colspan="1">
<html:submit>Save</html:submit>
</td>
</tr>
</table>
<input type="hidden" name="request_time" value="<%=System.currentTimeMillis()%>" />
</html:form>
</div>
<div class="bottom"></div>
</div>
</div>
</div><div id="end_body"></div>
</body>
</html> |
Supposant j'entre un client avec nom = é
le client est insere dans ma base et aussi affiche dans la page : listClient.jps :
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
|
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ page language="java"%>
<%@ taglib uri='/WEB-INF/struts-bean.tld' prefix='bean'%>
<%@ taglib uri='/WEB-INF/struts-html.tld' prefix='html'%>
<%@ taglib uri='/WEB-INF/struts-logic.tld' prefix='logic'%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-image: url(/GestionClientMeditel/form/images/rouge.jpg);
}
.Style1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style></head>
<body>
<table width="162" height="88" border="1" align="right">
<tr>
<td width="152" height="82"><img src="/GestionClientMeditel/form/images/logo_meditel.jpg" width="152" height="77"></td>
</tr>
</table>
<p> </p>
<p> </p>
<table width="335" border="1" align="center">
<tr>
<td width="325"><p class="Style1">LA LISTE DES CLIENTS EN TRAITEMENT </p> </td>
</tr>
</table>
<p> </p>
<table width="757" border="1">
<tr>
<td class="Style1">CLIENT</td>
<td class="Style1">ADRESSE</td>
<td class="Style1">LATITUDE</td>
<td class="Style1">LONGITUDE</td>
<td class="Style1">HAUTEUR</td>
<td class="Style1">CONTACT NOM </td>
<td class="Style1">CONTACT NUM</td>
<td class="Style1">DATE AJOUT </td>
<td class="Style1">BESOIN</td>
<td class="Style1">CAPACITE</td>
</tr>
<logic:empty name="clientForm" property="clients">
<tr>
<td colspan="5">Tous Les Clients Sont Servis</td>
</tr>
</logic:empty>
<logic:notEmpty name="clientForm" property="clients">
<logic:iterate name="clientForm" property="clients" id="client">
<tr>
<td width="325"><p class="Style1"><bean:write name="client" property="nom" /></td>
<td width="325"><p class="Style1"><bean:write name="client" property="adresse" /></td>
<td class="Style1"><bean:write name="client" property="latitude" /></td>
<td class="Style1"><bean:write name="client" property="longitude" /></td>
<td class="Style1"><bean:write name="client" property="hauteursite" /></td>
<td class="Style1"><bean:write name="client" property="contactnom" /></td>
<td class="Style1"><bean:write name="client" property="contactnum" /></td>
<td class="Style1"><bean:write name="client" property="dateajout" /></td>
<td class="Style1"><bean:write name="client" property="besoin" /></td>
<td class="Style1"><bean:write name="client" property="capacite" /></td>
<td class="Style1"><html:link action="suivi.do"
paramName="client"
paramProperty="nom"
paramId="nom"
>Suivi</html:link></td>
<td class="Style1"><html:link action="clientEdit.do?do=editClient"
paramName="client"
paramProperty="nom"
paramId="nom"
>Modifier</html:link></td>
<td class="Style1"><html:link action="viewClients.do?do=deleteClient"
paramName="client"
paramProperty="nom"
paramId="nom">Supprimer</html:link></td>
</tr>
</logic:iterate>
</logic:notEmpty>
</table>
<p> </p>
<div align="center"><span class="Style4"><a href="/GestionClientMeditel/form/menu.jsp" class="Style2">RETOUR AU MENU PRINCIPAL</a> </span></div>
</body>
</html> |
Dans ce code y a un lien pour modifier les donnees du client:
avec comme page :
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
| <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ page language="java"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Modification des Données du Client</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-image: url(/GestionClientMeditel/form/images/rouge.jpg);
}
.Style1 {
color: #FFFFFF;
font-weight: bold;
}
.Style2 {
font-size: 24px;
text-decoration: blink;
}
-->
</style></head>
<body>
<html:form action="clientEdit.do">
<table width="162" height="88" border="1" align="right">
<tr>
<td width="152" height="82"><img src="/GestionClientMeditel/form/images/logo_meditel.jpg" width="152" height="77"></td>
</tr>
</table>
<p> </p>
<p> </p>
<table width="379" border="0" align="center">
<tr>
<td width="369" class="Style1 Style2">Entrer les nouvelles données du Client : </td>
</tr>
</table>
<p> </p>
<p> </p>
<table width="688" border="0">
<tr>
<td width="177" class="Style1"><strong>Site Name</strong>:</td>
<td><html:text property="nom"/><html:errors property="nom"/><br/><td/>
<td width="161"> </td>
<td width="165"> </td>
</tr>
<tr>
<td><span class="Style1">Site Street Address</span></td>
<td><html:text property="adresse"/><html:errors property="adresse"/><br/><td/>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="Style1">Site Latitude </td>
<td><html:text property="latitude"/><html:errors property="latitude"/><br/><td/>
<td class="Style1">Site Longitude </td>
<td><html:text property="longitude"/><html:errors property="longitude"/><br/><td/>
</tr>
<tr>
<td class="Style1">Building Height </td>
<td><html:text property="hauteursite"/><html:errors property="hauteursite"/><br/><td/>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="Style1">Contact Name </td>
<td><html:text property="contactnom"/><html:errors property="contactnom"/><br/><td/>
<td class="Style1">Contact Tel </td>
<td><html:text property="contactnum"/><html:errors property="contactnum"/><br/><td/>
</tr>
<tr>
<td class="Style1">Date</td>
<td><html:text property="dateajout"/><html:errors property="dateajout"/><br/><td/>
<td> </td>
<td> </td>
</tr>
<tr>
<td><html:select property="besoin">
<html:option value="Voix IP">Voix IP</html:option>
<html:option value="Internet">Internet</html:option>
<html:option value="Data">Data</html:option>
<html:option value="Voix TDM / Internet">Voix TDM / Internet</html:option>
<html:option value="Voix TDM / Data">Voix TDM / Data</html:option>
<html:option value="Voix IP / Internet">Voix IP / Internet</html:option>
<html:option value="Voix IP / Data">Voix IP / Data</html:option>
<html:option value="Internet / Data">Internet / Data</html:option>
<html:option value="Voix TDM / Internet / Data">Voix TDM / Internet / Data</html:option>
<html:option value="Voix IP / Internet / Data">Voix IP / Internet / Data</html:option>
</html:select>
<html:errors property="fonction"/><br/><td/>
<td class="Style1">Capacite</td>
<td><html:text property="capacite"/><html:errors property="capacite"/><br/><td/>
</tr>
<tr>
<td colspan="1">
<html:submit>Sauvegarder</html:submit>
</td>
</tr>
<html:hidden property="nom" />
</table>
<%-- set the parameter for the dispatch action --%>
<html:hidden property="do" value="saveClient" />
</html:form>
</div>
<div class="bottom"></div>
</div>
</div>
</div><div id="end_body"></div>
</body>
</html> |
voici l'action :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
<action
attribute="clientEditForm"
name="clientEditForm"
path="/clientEdit"
parameter="do"
validate="false"
scope="request"
type="com.gestionclientmeditel.struts.action.ClientEditAction">
<forward name="showEdit" path="/form/clientEdit.jsp" />
<forward
name="showList"
path="/viewClients.do?do=showClients"
redirect="true" />
</action> |
et comme bean , le meme bean de l'ajout et comme form :
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 146 147 148 149 150 151 152 153 154 155 156
|
package com.gestionclientmeditel.struts.form;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import com.gestionclientmeditel.persistance.ClientBean;
public class ClientEditForm extends ActionForm {
private ClientBean clientBean =new ClientBean();
private Collection clients;
public void setClients(Collection c){
clients=c;
}
public Collection getClients(){
return clients;
}
public ClientBean getClientBean(){
return clientBean;
}
public void setClientBean(ClientBean clientBean){
this.clientBean=clientBean;
}
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request){
return null;
}
public void reset(ActionMapping mapping,HttpServletRequest request){
}
public boolean equals(Object arg0){
return clientBean.equals(arg0);
}
public String toString(){
return clientBean.toString();
}
public int hashCode(){
return clientBean.hashCode();
}
///////////////////////////////////////////////////////////
public String getNom() {
return clientBean.getNom();
}
public void setNom(String nom){
clientBean.setNom(nom);
}
public int getEtape() {
return clientBean.getEtape();
}
public void setEtape(int etape){
clientBean.setEtape(etape);
}
public String getAdresse() {
return clientBean.getAdresse();
}
public void setAdresse(String adresse){
clientBean.setAdresse(adresse);
}
public String getBesoin() {
return clientBean.getBesoin();
}
public void setBesoin(String besoin){
clientBean.setBesoin(besoin);
}
public String getContactnom() {
return clientBean.getContactnom();
}
public void setContactnom(String contactnom){
clientBean.setContactnom(contactnom);
}
public String getContactnum() {
return clientBean.getContactnum();
}
public void setContactnum(String contactnum){
clientBean.setContactnum(contactnum);
}
public String getCapacite() {
return clientBean.getCapacite();
}
/**
* @param capacite The capacite to set.
*/
public void setCapacite(String capacite) {
this.clientBean.setCapacite(capacite);
}
/**
* @return Returns the dateajout.
*/
public String getDateajout() {
return clientBean.getDateajout();
}
/**
* @param dateajout The dateajout to set.
*/
public void setDateajout(String dateajout) {
this.clientBean.setDateajout(dateajout);
}
/**
* @return Returns the hauteursite.
*/
public String getHauteursite() {
return clientBean.getHauteursite();
}
/**
* @param hauteursite The hauteursite to set.
*/
public void setHauteursite(String hauteursite) {
this.clientBean.setHauteursite(hauteursite);
}
/**
* @return Returns the latitude.
*/
public String getLatitude() {
return clientBean.getLatitude();
}
/**
* @param latitude The latitude to set.
*/
public void setLatitude(String latitude) {
this.clientBean.setLatitude(latitude);
}
/**
* @return Returns the longitude.
*/
public String getLongitude() {
return clientBean.getLongitude();
}
/**
* @param longitude The longitude to set.
*/
public void setLongitude(String longitude) {
this.clientBean.setLongitude(longitude);
}
} |
Quand je click sur modifier : dans le navigateur je vois le lien :
http://localhost:8443/GestionClientMeditel/clientEdit.do?do=editClient&nom=%22%C3%A9
!!!!!! nom=%22%C3%A9
donc il y a un conflit de codage de caractere speciaux dans ma page...
A toi de voir.
merci encore
Partager