IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Servlets/JSP Java Discussion :

Servlet hibernate Distinct


Sujet :

Servlets/JSP Java

  1. #1
    Nouveau membre du Club
    Inscrit en
    Janvier 2011
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Janvier 2011
    Messages : 114
    Points : 30
    Points
    30
    Par défaut Servlet hibernate Distinct
    Bonjour j'ai un problème dans mon code hibernate je veux créer une requête distinct en langage hql mais ca marche pas voici le code
    if (action.equals("new")) {
    List<Client> clients = null;
    Query q = sessionDb.createQuery("select distinct (c.nom) from Client c");
    clients = q.list();
    request.setAttribute("clients", clients);
    CommandeClient nouvelleCommande = new CommandeClient();

    //nouvelleCommande.setReference("" + Calendar.getInstance().get(Calendar.YEAR));
    if (session.getAttribute("commandenew") == null)
    session.setAttribute("commandenew", nouvelleCommande);
    gotoPage("/jsp/commande/new.jsp", request, response);
    }
    else if (action.equals("annuler")) {
    session.removeAttribute("commandenew");
    response.sendRedirect("commande?op=new");
    }
    et l'erreur qui m'affiche
    org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: Property 'id' not found on type java.lang.String
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    servlets.commande.Commande.gotoPage(Commande.java:464)
    servlets.commande.Commande.doGet(Commande.java:76)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    merci pour vos aides

  2. #2
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    Bonjour

    c'est comme je te disais dans nos échanges précédents, c'est difficile d'avancer dans ton projet sans DAO et ton application va devenir de plus en plus ingérable. En lisant mieux les traces et en faisant un DAO tu aurais pu tester ta méthode de manière indépendante et tu te serais rendu compte que ce n'est pas ta requête qui pose problème (enfin selon les logs ce n'est pas ta requête qui a l'air de poser problème pour l'instant ...)

    Je te conseille d'essayer de convaincre les personnes de changer d'avis
    Sinon l'erreur qui est renvoyée ne vient pas de ta requête HQL mais plutôt de ta JSP ou du paramétrage de ton struts-config.xml

    est-ce que tu poster des deux fichiers stp ?

  3. #3
    Nouveau membre du Club
    Inscrit en
    Janvier 2011
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Janvier 2011
    Messages : 114
    Points : 30
    Points
    30
    Par défaut
    merci infiniment je ne travailles pas avec struts seulement hibernate voici le code de la jsp

    <form name="cmd" action="<%= reqUrl %>/commande?" method="post" onsubmit="return validate();">
    <input type="hidden" name="op" value="new"/>
    <p style="background-color: #CCFFCC;padding: 5px;">
    <label for="objet">Objet </label><input type="text" name="objet" value=""></input>

    <br/>
    </p>
    <p style="background-color: #FFD400;padding: 5px;">
    <input style="float: right;" onclick="affichage_popup_ajout_client();" type="button" value="Ajouter Patient"></input>
    <label for="reference">Patient </label>
    <select name="client_id">
    <option value=""></option>
    <c:forEach var="client" items="${clients}" varStatus="loopStatus">
    <option value="${client.id}">${client.nom}</option>
    </c:forEach>
    </select>

    </p>

    <h3>Listes produits à commander (${fn:length(sessionScope.commandenew.produits_commandes)})<div style="float: right;"><input onclick="affichage_popup_liste_produits();" type="button" value="Ajouter Produit"></input></div></h3>
    <c:if test="${not empty sessionScope.commandenew.produits_commandes}">
    <table id="liste_produits" class="tablesorter" cellspacing="1">
    <thead>
    <tr>
    <th># Réf</th>
    <th>Prix Vente</th>
    <th>Quantité commandée</th>
    </tr>
    </thead>

    <c:forEach var="produitCommande" items="${sessionScope.commandenew.produits_commandes}" varStatus="loopStatus">
    <tr>
    <td>
    <input type="hidden" name="produitcommande_${loopStatus.index}" value="${produitCommande.id}" />
    <input type="hidden" name="prt_${loopStatus.index}" value="${produitCommande.produit.id}" />
    ${produitCommande.produit.reference}
    </td>
    <td style="background-color: #FFFF99;"><input type="text" name="prixVente_${loopStatus.index}" value="${produitCommande.prix_vente}"></td>
    <td style="background-color: #CCFFFF;"><input type="text" name="quantitecommandee_${loopStatus.index}" value="${produitCommande.quantite_commandee}"></td>
    </tr>
    </c:forEach>
    </table>
    </c:if>
    <p>
    <input type="submit"></input><a href="<%= reqUrl %>/commande?op=annuler">Annuler</a>
    </p>
    </form>

  4. #4
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    A priori l'erreur doit provenir d'une des lignes suivantes:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <option value="${client.id}">${client.nom}</option>
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    <input type="hidden" name="produitcommande_${loopStatus.index}" value="${produitCommande.id}" />
    <input type="hidden" name="prt_${loopStatus.index}" value="${produitCommande.produit.id}" />
    Est-ce que tu peux poster tes trois classes Java correspondants aux objets produitCommande , produit et client?

    D'après les logs une des classes ne possède pas l'attribut id

  5. #5
    Nouveau membre du Club
    Inscrit en
    Janvier 2011
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Janvier 2011
    Messages : 114
    Points : 30
    Points
    30
    Par défaut
    merci, voici le code de produitCommandeClient
    package domain;

    import java.io.Serializable;

    public class ProduitCommandeClient implements Serializable, Comparable {

    private static final long serialVersionUID = 1L;
    public Integer id;
    public Produit produit;
    public CommandeClient commandeClient;
    public int quantite_commandee;
    public float prix_vente;
    public float calcul;

    public ProduitCommandeClient() {
    }
    public ProduitCommandeClient(Produit produit2) {
    this.setProduit(produit2);
    }
    public Integer getId() {
    return id;
    }
    public void setId(Integer id) {
    this.id = id;
    }
    public Produit getProduit() {
    return produit;
    }
    public void setProduit(Produit produit) {
    this.produit = produit;
    }
    public CommandeClient getCommandeClient() {
    return commandeClient;
    }
    public void setCommandeClient(CommandeClient commandeClient) {
    this.commandeClient = commandeClient;
    }
    public int getQuantite_commandee() {
    return quantite_commandee;
    }
    public void setQuantite_commandee(int quantiteCommandee) {
    quantite_commandee = quantiteCommandee;
    }
    public float getPrix_vente() {
    return prix_vente;
    }
    public void setPrix_vente(float prix_vente) {
    this.prix_vente = prix_vente;
    }



    @Override
    public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + Float.floatToIntBits(calcul);
    result = prime * result
    + ((commandeClient == null) ? 0 : commandeClient.hashCode());
    result = prime * result + ((id == null) ? 0 : id.hashCode());
    result = prime * result + Float.floatToIntBits(prix_vente);
    result = prime * result + ((produit == null) ? 0 : produit.hashCode());
    result = prime * result + quantite_commandee;
    return result;
    }
    @Override
    public boolean equals(Object obj) {
    if (this == obj)
    return true;
    if (obj == null)
    return false;
    if (getClass() != obj.getClass())
    return false;
    ProduitCommandeClient other = (ProduitCommandeClient) obj;
    if (Float.floatToIntBits(calcul) != Float.floatToIntBits(other.calcul))
    return false;
    if (commandeClient == null) {
    if (other.commandeClient != null)
    return false;
    } else if (!commandeClient.equals(other.commandeClient))
    return false;
    if (id == null) {
    if (other.id != null)
    return false;
    } else if (!id.equals(other.id))
    return false;
    if (Float.floatToIntBits(prix_vente) != Float
    .floatToIntBits(other.prix_vente))
    return false;
    if (produit == null) {
    if (other.produit != null)
    return false;
    } else if (!produit.equals(other.produit))
    return false;
    if (quantite_commandee != other.quantite_commandee)
    return false;
    return true;
    }
    @Override
    public int compareTo(Object o) {
    return produit.getId();
    }

    public float getCalcul() {
    return calcul=(getPrix_vente()*getQuantite_commandee());
    }
    public void setCalcul(float calcul){
    calcul=(getPrix_vente())*(getQuantite_commandee());

    }


    }
    Pour client

    package domain;

    import java.util.Date;
    import java.util.Set;
    import java.util.TreeSet;


    public class Client {

    public Integer id;
    public String nom;
    public String prenom;
    public String adresse;
    public String telephone;
    public String raison_sociale;
    public String nom_mededin;
    public String beneficiare;
    public Date date_operation;
    public Date date_accident;
    public Date date_creation;
    public Date date_mise_jour;
    private Set<CommandeClient> commandes= new TreeSet<CommandeClient>();

    public Integer getId() {
    return id;
    }
    public void setId(Integer id) {
    this.id = id;
    }
    public String getNom() {
    return nom;
    }
    public void setNom(String nom) {
    this.nom = nom;
    }
    public String getPrenom() {
    return prenom;
    }
    public void setPrenom(String prenom) {
    this.prenom = prenom;
    }
    public String getAdresse() {
    return adresse;
    }
    public void setAdresse(String adresse) {
    this.adresse = adresse;
    }
    public String getTelephone() {
    return telephone;
    }
    public void setTelephone(String telephone) {
    this.telephone = telephone;
    }
    public String getRaison_sociale() {
    return raison_sociale;
    }
    public void setRaison_sociale(String raisonSociale) {
    raison_sociale = raisonSociale;
    }
    public String getNom_mededin() {
    return nom_mededin;
    }
    public void setNom_mededin(String nomMededin) {
    nom_mededin = nomMededin;
    }
    public String getBeneficiare() {
    return beneficiare;
    }
    public void setBeneficiare(String beneficiare) {
    this.beneficiare = beneficiare;
    }
    public Date getDate_operation() {
    return date_operation;
    }
    public void setDate_operation(Date date_operation) {
    this.date_operation = date_operation;
    }
    public Date getDate_accident() {
    return date_accident;
    }
    public void setDate_accident(Date date_accident) {
    this.date_accident = date_accident;
    }
    public Date getDate_creation() {
    return date_creation;
    }
    public void setDate_creation(Date dateCreation) {
    date_creation = dateCreation;
    }
    public Date getDate_mise_jour() {
    return date_mise_jour;
    }
    public void setDate_mise_jour(Date dateMiseJour) {
    date_mise_jour = dateMiseJour;
    }
    public Set<CommandeClient> getCommandes() {
    return commandes;
    }
    public void setCommandes(Set<CommandeClient> commandes) {
    this.commandes = commandes;
    }
    public String getNomPrenom() {
    return prenom + " " + nom;
    }


    }

    Pour produit

    package domain;

    import java.util.Date;

    public class Produit {

    public Integer id;
    public String reference;
    public String designation;
    public String taille;
    public float prix_achat;
    public float prix_vente;
    public int quantite_stock;
    public Date date_creation;
    public Date date_mise_jour;

    public Integer getId() {
    return id;
    }
    public void setId(Integer id) {
    this.id = id;
    }
    public String getReference() {
    return reference;
    }
    public void setReference(String reference) {
    this.reference = reference;
    }
    public String getDesignation() {
    return designation;
    }
    public void setDesignation(String designation) {
    this.designation = designation;
    }
    public String getTaille() {
    return taille;
    }
    public void setTaille(String taille) {
    this.taille = taille;
    }
    public float getPrix_achat() {
    return prix_achat;
    }
    public void setPrix_achat(float prixAchat) {
    prix_achat = prixAchat;
    }
    public float getPrix_vente() {
    return prix_vente;
    }
    public void setPrix_vente(float prixVente) {
    prix_vente = prixVente;
    }
    public int getQuantite_stock() {
    return quantite_stock;
    }
    public void setQuantite_stock(int quantiteStock) {
    quantite_stock = quantiteStock;
    }
    public Date getDate_creation() {
    return date_creation;
    }
    public void setDate_creation(Date dateCreation) {
    date_creation = dateCreation;
    }
    public Date getDate_mise_jour() {
    return date_mise_jour;
    }
    public void setDate_mise_jour(Date dateMiseJour) {
    date_mise_jour = dateMiseJour;
    }



    }

  6. #6
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    Est-ce que tu peux poster la stack trace complete qui provient du fichier catalina.out stp ?

  7. #7
    Nouveau membre du Club
    Inscrit en
    Janvier 2011
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Janvier 2011
    Messages : 114
    Points : 30
    Points
    30
    Par défaut
    Désole j'ai pas bien compris

  8. #8
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    Est-ce que tu utilises Tomcat ? et si oui est-ce que tu peux poster le message d'erreur qui se trouve dans le fichier catalina.out que tu trouveras dans le répértoire Tomcat/logs

  9. #9
    Nouveau membre du Club
    Inscrit en
    Janvier 2011
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Janvier 2011
    Messages : 114
    Points : 30
    Points
    30
    Par défaut
    merci,oui voici l'erreur

    org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: Property 'id' not found on type java.lang.String
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    servlets.commande.Commande.gotoPage(Commande.java:464)
    servlets.commande.Commande.doGet(Commande.java:76)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    cause m�re

    javax.el.PropertyNotFoundException: Property 'id' not found on type java.lang.String
    javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:193)
    javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:170)
    javax.el.BeanELResolver.property(BeanELResolver.java:279)
    javax.el.BeanELResolver.getValue(BeanELResolver.java:60)
    javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
    org.apache.el.parser.AstValue.getValue(AstValue.java:118)
    org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
    org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:925)
    org.apache.jsp.jsp.commande.new_jsp._jspx_meth_c_005fforEach_005f0(new_jsp.java:304)
    org.apache.jsp.jsp.commande.new_jsp._jspService(new_jsp.java:225)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    servlets.commande.Commande.gotoPage(Commande.java:464)
    servlets.commande.Commande.doGet(Commande.java:76)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    et pour le fichier catalina out je ne l'ai pas trouvé dans le répertoire logs j'ai seulemet trouver des fichiers nommés catalina.

  10. #10
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    le problème vient donc de ta boucle c:foreach

    est-ce que tu peux poster la classe CommandeClient.java stp ?

  11. #11
    Nouveau membre du Club
    Inscrit en
    Janvier 2011
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Janvier 2011
    Messages : 114
    Points : 30
    Points
    30
    Par défaut
    merci, voici la classe commandeClient

    package domain;

    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    import java.util.Set;
    import java.util.TreeSet;

    public class CommandeClient {

    public Integer id;
    public String reference;
    public Client client;
    public String objet;
    public float total_prix;
    public Date date_creation;
    public Date date_mise_jour;
    public boolean etatPaye;
    public boolean etatLivrer;
    public int nbreproduits;
    public Set<ProduitCommandeClient> produits_commandes = new TreeSet<ProduitCommandeClient>();

    public Integer getId() {
    return id;
    }

    public void setId(Integer id) {
    this.id = id;
    }

    public String getReference() {
    return reference;
    }

    public void setReference(String reference) {
    this.reference = reference;
    }

    public Client getClient() {
    return client;
    }

    public void setClient(Client client) {
    this.client = client;
    }
    public String getObjet() {
    return objet;
    }

    public void setObjet(String objet) {
    this.objet = objet;
    }
    public float getTotal_prix() {
    return total_prix;
    }

    public void setTotal_prix(float totalPrix) {
    total_prix = totalPrix;

    }

    public void setTotal_prix() {
    for (ProduitCommandeClient p : produits_commandes)
    total_prix += p.prix_vente * p.quantite_commandee;
    }

    public Date getDate_creation() {
    return date_creation;
    }

    public void setDate_creation(Date dateCreation) {
    date_creation = dateCreation;
    }

    public Date getDate_mise_jour() {
    return date_mise_jour;
    }

    public void setDate_mise_jour(Date dateMiseJour) {
    date_mise_jour = dateMiseJour;
    }

    public Set<ProduitCommandeClient> getProduits_commandes() {
    return produits_commandes;
    }

    public void setProduits_commandes(
    Set<ProduitCommandeClient> produits_commandes) {
    this.produits_commandes = produits_commandes;
    }

    public boolean isEtatPaye() {
    return etatPaye;
    }

    public void setEtatPaye(boolean etatPaye) {
    this.etatPaye = etatPaye;
    }

    public boolean isEtatLivrer() {
    return etatLivrer;
    }

    public void setEtatLivrer(boolean etatLivrer) {
    this.etatLivrer = etatLivrer;
    }

    public List<Integer> getIdProduitsCommande() {
    List<Integer> liste = new ArrayList<Integer>();
    for (ProduitCommandeClient produitCommandeClient : produits_commandes) {
    liste.add(produitCommandeClient.getProduit().getId());
    }
    return liste;
    }

    public ProduitCommandeClient getProduitCommandeClientById(Integer id) {
    for (ProduitCommandeClient produitCommandeClient : produits_commandes) {
    if (produitCommandeClient.getId() == id) return produitCommandeClient;
    }
    return null;
    }

    public void addProduitCommande(ProduitCommandeClient p) {
    getProduits_commandes().add(p);
    p.setCommandeClient(this);
    }
    }

  12. #12
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    Au fait la ligne 225 correspond à quoi dans ta jSP new

  13. #13
    Nouveau membre du Club
    Inscrit en
    Janvier 2011
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Janvier 2011
    Messages : 114
    Points : 30
    Points
    30
    Par défaut
    la ligne 255?

  14. #14
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    oui dans ta JSP new.jsp
    Est-ce que tu peux dire à quoi correspond la ligne 255 (c'est celle qui est indiquée dans ton fichier de log...) dans ta JSP new.jsp

  15. #15
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    je crois que c'est la ligne qui correspond à

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <c:forEach var="client" items="${clients}" varStatus="loopStatus">
    <option value="${client.id}">${client.nom}</option>
    </c:forEach>
    et dans ta servlet tu n'as pas mis :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    session.setAttribute("clients", clients);
    où l'objet clients est à définir

    d'ailleurs pour faire un test tu peux supprimer cette partie là de ta JSP et tu verras si elle s'affiche correctement

  16. #16
    Nouveau membre du Club
    Inscrit en
    Janvier 2011
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Janvier 2011
    Messages : 114
    Points : 30
    Points
    30
    Par défaut
    la réalité je ne sais pas

  17. #17
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    1) Est-ce que tu peux essayer ce que j'ai mis dans mon dernier post :c'est à dire supprimer le code suivant dans ta JSP. Et ensuite, tu essaies d'afficher ta page

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    <p style="background-color: #FFD400;padding: 5px;">
    <input style="float: right;" onclick="affichage_popup_ajout_client();" type="button" value="Ajouter Patient"></input>
    <label for="reference">Patient </label>
    <select name="client_id">
    <option value=""></option>
    <c:forEach var="client" items="${clients}" varStatus="loopStatus">
    <option value="${client.id}">${client.nom}</option>
    </c:forEach>
    </select>
     
    </p>

    2) Quel est l'éditeur que tu utilises stp pour créer tes pages JSP , java etc ..?

  18. #18
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    Alors est-ce que tu as réussi à supprimer le code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    <p style="background-color: #FFD400;padding: 5px;">
    <input style="float: right;" onclick="affichage_popup_ajout_client();" type="button" value="Ajouter Patient"></input>
    <label for="reference">Patient </label>
    <select name="client_id">
    <option value=""></option>
    <c:forEach var="client" items="${clients}" varStatus="loopStatus">
    <option value="${client.id}">${client.nom}</option>
    </c:forEach>
    </select>
     
    </p>
    de ta jSP new.jsp et à afficher ta page new.jsp ?

  19. #19
    Nouveau membre du Club
    Inscrit en
    Janvier 2011
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Janvier 2011
    Messages : 114
    Points : 30
    Points
    30
    Par défaut
    merci pour vos réponses j'ai supprimer le code que vous m'avez indiquer ma page jsp new s'affiche sans le select du client. mais je ne sais pas comment faire pour utiliser le distinct pour l'éditeur je travaille sous eclipse. pourriez vous m'aider? merci

  20. #20
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    Il faut vérifier deux points :

    1) quel est le retour de la requête
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    select distinct (c.nom) from Client c
    2) et sinon essaie de mettre ton objet clients en session et remets le code que tu as supprimé dans ta jsp

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    session.setAttribute("clients", clients);

Discussions similaires

  1. Coordination entre servlet + Hibernate
    Par abdoulfall dans le forum Autres
    Réponses: 10
    Dernier message: 20/02/2012, 09h27
  2. Erreur servlet hibernate: id to load is required for loading
    Par salma309 dans le forum Servlets/JSP
    Réponses: 6
    Dernier message: 14/03/2011, 15h26
  3. problème de servlet et hibernate
    Par meryeminfo dans le forum Servlets/JSP
    Réponses: 6
    Dernier message: 04/09/2009, 15h28
  4. Réponses: 0
    Dernier message: 09/10/2007, 03h10
  5. Problème de lancement Servlet avec Hibernate
    Par jamy79 dans le forum Hibernate
    Réponses: 2
    Dernier message: 24/11/2006, 11h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo