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

JSF Java Discussion :

Problème de suppression via JSF


Sujet :

JSF Java

  1. #1
    Membre éclairé
    Homme Profil pro
    Inscrit en
    Mai 2011
    Messages
    790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Mai 2011
    Messages : 790
    Par défaut Problème de suppression via JSF
    J'ai un petit problème concernant la suppression d'une ligne deja existante et j'ai pas trouvé ce problème.J'ai vraiment besoin de votre aide voici le code:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    import java.util.ArrayList;
    import java.util.List;
     
    import javax.faces.model.DataModel;
    import javax.faces.model.ListDataModel;
     
    import org.hibernate.Session;
    import org.hibernate.Transaction;
     
    import com.dao.ContactDao;
    import com.dao.imp.ContactDaoImp;
    import com.model.Contact;
    import com.model.Utilisateur;
    import com.util.hibernateutil;
     
     
     
     
    public class ContactCtr   {
     
    	private String numPieceCnt;
    	private String nomNomCnt;
    	private String nomPreCnt;
    	private String adrAdrCnt;
    	private String numGsmCnt;
    	private String codTpceCnt;
    	private List<Contact> contact=new ArrayList<Contact>();
     
     
    	ContactDao Cont= new ContactDaoImp();
     
     
        private DataModel ct;
     
     
     
     
     
    	public DataModel getCt() {
     
    		    ct= new ListDataModel();
     
    			ct.setWrappedData(Cont.findallContact());
     
    		return ct;
    	}
     
    	public void setContact(List<Contact> contact) {
    		this.contact = contact;
    	}
     
    	public String getNumPieceCnt() {
    		return this.numPieceCnt;
    	}
     
    	public void setNumPieceCnt(String numPieceCnt) {
    		this.numPieceCnt = numPieceCnt;
    	}
     
    	public String getNomNomCnt() {
    		return this.nomNomCnt;
    	}
     
    	public void setNomNomCnt(String nomNomCnt) {
    		this.nomNomCnt = nomNomCnt;
    	}
     
    	public String getNomPreCnt() {
    		return this.nomPreCnt;
    	}
     
    	public void setNomPreCnt(String nomPreCnt) {
    		this.nomPreCnt = nomPreCnt;
    	}
     
     
    	public String getAdrAdrCnt() {
    		return this.adrAdrCnt;
    	}
     
    	public void setAdrAdrCnt(String adrAdrCnt) {
    		this.adrAdrCnt = adrAdrCnt;
    	}
     
     
    	public String getNumGsmCnt() {
    		return this.numGsmCnt;
    	}
     
    	public void setNumGsmCnt(String numGsmCnt) {
    		this.numGsmCnt = numGsmCnt;
    	}
     
     
    	public String getCodTpceCnt() {
    		return this.codTpceCnt;
    	}
     
    	public void setCodTpceCnt(String codTpceCnt) {
    		this.codTpceCnt = codTpceCnt;
    	}
     
     
     
     
     
    	public String deleteContact() {
    		Contact c = (Contact) ct.getRowData();
    		Cont.delete(ct);
    		ct.setWrappedData(Cont.findallContact());
    		return"success";
    	}
     
     
     
     
     
     
    		}

    et ma page jsf et celle ci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
    <head>
    <title>Gestion</title>
    </head>
    <body>
    <ui:decorate template="../template/template.xhtml">
     
    <ui:define name="body">
    <f:view>
     <h:form >
     
     <div align="center">
    	<rich:dataTable border="1" rules="all" value="#{Con.ct}" var="contact">
     
                <h:column>
    			<f:facet name="header">
    	        <h:outputText value="NumeroPiece" />
    			</f:facet>
    			<h:outputText value="#{contact.numPieceCnt}" />
    			</h:column>
     
     
     
     
     
     
     
    		<h:column>
    			<f:facet name="header">
    				<h:outputText value="Prénom" />
    			</f:facet>
    			<h:outputText value="#{contact.nomPreCnt}" />
    		</h:column>
     
     
    		<h:column>
    			<f:facet name="header">
    				<h:outputText value="Nom" />
    			</f:facet>
    			<h:outputText value="#{contact.nomNomCnt}" />
    		</h:column>
     
    		<h:column>
    			<f:facet name="header">
    				<h:outputText value="Adresse" />
    			</f:facet>
    			<h:outputText value="#{contact.adrAdrCnt}" />
    		</h:column>
     
     
    		<h:column>
    			<f:facet name="header">
    				<h:outputText value="Gsm" />
    			</f:facet>
    			<h:outputText value="#{contact.numGsmCnt}" />
    		</h:column>
     
    		<h:column>
    			<f:facet name="header">
    				<h:outputText value="TypePiece" />
    			</f:facet>
    			<h:outputText value="#{contact.codTpceCnt}" />
    		</h:column>
     
    		<h:column>
    	<f:facet name="header">
    		<h:outputText value="Suppression" />
    	</f:facet>
    	 <h:commandButton value="supprimer" action="#{Con.deleteContact}">   
     
        </h:commandButton> 
    </h:column>
     
     
     
    </rich:dataTable>
    </div> 
     
     
     
     
     
     
     
     </h:form>
     </f:view>
     </ui:define>
     </ui:decorate>
     </body>
     </html>

    et j'obtiens l'erreur suivante:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    exception 
     
    javax.servlet.ServletException: #{Con.deleteContact}: org.hibernate.MappingException: Unknown entity: javax.faces.model.ListDataModel
    	javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
    	org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
    	org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    	org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
    	org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
     
     
    cause mère 
     
    javax.faces.FacesException: #{Con.deleteContact}: org.hibernate.MappingException: Unknown entity: javax.faces.model.ListDataModel
    	com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
    	javax.faces.component.UICommand.broadcast(UICommand.java:387)
    	org.ajax4jsf.component.UIDataAdaptor.broadcast(UIDataAdaptor.java:1383)
    	org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
    	org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
    	org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
    	org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
    	com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
    	com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    	com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    	javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
    	org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
    	org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    	org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
    	org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
    Merci

  2. #2
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Vous avez mis le DataModel dans un bean hibernate. Hibernante ne sais pas quoi faire de ça. Vous pouvez le déclarer transient dans hibernate, mais le mieux c'est d'éviter d'aller mélanger des trucs spécifiques à JSF à l'intérieur de vos Bean hibernate.


    De plus d'après votre xhtml vous appelez une méthode Con.deleteContact qui est sur votre bean jsf, et non pas contact.deleteContact => Je ne vois pas pourquoi il y a une méthode deleteContact dans votre bean hibernate.

  3. #3
    Membre éclairé
    Homme Profil pro
    Inscrit en
    Mai 2011
    Messages
    790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Mai 2011
    Messages : 790
    Par défaut
    Merci pour votre rèponse d'abord! ^^
    au fait j'ai appelé la methode deleteContact avec le bean "Con" car il reférence la classe ContactCtr et dans cette methode il ya l'appel du dao bien sur!
    J'ai deja fait un appel d'une methode d'ajout et ça marché mais avec la suppression et data model ça marche pas!
    Est ce que vous pouvez svp me faire expliquer comment je le declare dans hibernate? et merci encore pour votre rèponse de tout à l'heure

  4. #4
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    tu essaie d'effacer le datamodel et non l'objet contact récupéré à la ligne juste avant. Essaie de nomer plus explicitement tes variables pour éviter ce genre d'erreur à l'avenir.

  5. #5
    Membre éclairé
    Homme Profil pro
    Inscrit en
    Mai 2011
    Messages
    790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Mai 2011
    Messages : 790
    Par défaut
    waaaaaw j'ai pas fait attention à ça!!une faute vraiment fatal!! Merci encore une fois pour votre aide!
    1000 merci encore )))

Discussions similaires

  1. Problème de suppression de ligne dans ma base !
    Par gregman dans le forum ASP
    Réponses: 2
    Dernier message: 21/05/2005, 08h14
  2. Problème de suppression de fichier
    Par sorry60 dans le forum Assembleur
    Réponses: 7
    Dernier message: 23/04/2005, 18h33
  3. [JTable] problème après suppression d'une ligne
    Par fredo3500 dans le forum Composants
    Réponses: 7
    Dernier message: 17/03/2005, 10h01
  4. [Excel - VBA] Problème de suppression de lignes...
    Par beholder2 dans le forum Macros et VBA Excel
    Réponses: 8
    Dernier message: 28/01/2005, 17h27
  5. Réponses: 4
    Dernier message: 16/04/2004, 08h20

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