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

Struts 1 Java Discussion :

No getter method available for property


Sujet :

Struts 1 Java

  1. #1
    Futur Membre du Club
    Inscrit en
    Décembre 2008
    Messages
    9
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 9
    Points : 6
    Points
    6
    Par défaut No getter method available for property
    Bonjour,
    j'ai besoin d'aide SVP ,je veux initialiser une liste (HashSet) d'objet à partir d'une jsp mais j'ai l'erreur suivante:

    exception

    javax.servlet.ServletException: org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: No getter method available for property dateDebut for bean under name org.apache.struts.taglib.html.BEAN
    org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    cause mère

    org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: No getter method available for property dateDebut for bean under name org.apache.struts.taglib.html.BEAN
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
    voici mes ressources:
    creer_cv.jsp
    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
     
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    	pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@taglib prefix="html" uri="http://struts.apache.org/tags-html"%>
    <%@taglib prefix="nested" uri="http://struts.apache.org/tags-nested" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <script type="text/javascript">
     
    </script>
    </head>
    <body>
    <html:form action="/creer_cv2.do" method="post">
    	<table>
    		<tr>
    			<td>Titre CV: <html:text property="titreCv" name="cv" /></td>
    		</tr>
    		<tr>
    			<td>
    			<fieldset><legend>Formations:</legend>
    			<table>
    				<tr>
    					<td>Date Début</td>
    					<td>Date Fin</td>
    					<td>Ou à aujourdhui</td>
    				</tr>
    				<tr>
    					<td>
    	<html:text property="formations.dateDebut" name="cv" /></td>
    	<td><html:text property="formations.dateFin" name="cv" /></td>
    					<td><html:checkbox property="formations.dateFin" name="cv" /></td>
    				</tr>
    				<tr>
    					<td>Nom Formation</td>
    					<td>Type de Formation</td>
    					<td>Niveau Formation</td>
    				</tr>
    				<tr>
    					<td><html:text property="formations.titreFormation" name="cv" /></td>
    					<td><html:text
    						property="formations.typeFormation.libelleTypeFormation" name="cv" /></td>
    					<td><html:text
    						property="formations.nvFormation.libelleNvFormation" name="cv" /></td>
    				</tr>
    				<tr>
    					<td>Etablisement</td>
    					<td>Ville</td>
    					<td>Pays</td>
    				</tr>
    				<tr>
    					<td><html:text property="formations.etablissement" name="cv" /></td>
    					<td><html:text property="formations.ville" name="cv" /></td>
    					<td><html:text property="formations.paye" name="cv" /></td>
    				</tr>
    				<tr>
    					<td colspan="3">Description Formation</td>
    				</tr>
    				<tr>
    					<td colspan="3"><html:textarea
    						property="formations.descriptionFormation" name="cv"
    						style="width : 571px; height : 70px;" /></td>
    				</tr>
    				<tr>
    					<td><html:submit value="Valider" /> <html:link
    						href="creer_cv.do" /></td>
    				</tr>
    			</table>
    			</fieldset>
    			</td>
    		</tr>
    		<tr>
    			<td></td>
    		</tr>
    		<tr>
    			<td></td>
    		</tr>
    		<tr>
    			<td></td>
    		</tr>
    		<tr>
    			<td></td>
    		</tr>
    	</table>
    </html:form>
    </body>
    </html>
    Cv.java
    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
     
    package modeles_candidat;
     
    import java.util.Date;
    import java.util.HashSet;
    import java.util.Set;
     
    import modeles_generale.Langue;
     
    public class Cv {
    	private String titreCv;
    	private Date dateCreationCv;
    	private Date dateModificationCv;
    	private String cheminCv;
    	private String competences;
    	private String divers;
    	private Set<Formation> formations = new HashSet<Formation>();
     
    	public Cv() {
    		// TODO Auto-generated constructor stub
    	}
     
    	public Cv(String titreCv, Date dateCreationCv, Date dateModificationCv,
    			String cheminCv, String competences, String divers,
    			Set<Formation> formations) {
    		super();
    		this.titreCv = titreCv;
    		this.dateCreationCv = dateCreationCv;
    		this.dateModificationCv = dateModificationCv;
    		this.cheminCv = cheminCv;
    		this.competences = competences;
    		this.divers = divers;
    		this.formations = formations;
     
    	}
     
    	public String getTitreCv() {
    		return titreCv;
    	}
     
    	public void setTitreCv(String titreCv) {
    		this.titreCv = titreCv;
    	}
     
    	public Date getDateCreationCv() {
    		return dateCreationCv;
    	}
     
    	public void setDateCreationCv(Date dateCreationCv) {
    		this.dateCreationCv = dateCreationCv;
    	}
     
    	public Date getDateModificationCv() {
    		return dateModificationCv;
    	}
     
    	public void setDateModificationCv(Date dateModificationCv) {
    		this.dateModificationCv = dateModificationCv;
    	}
     
    	public String getCheminCv() {
    		return cheminCv;
    	}
     
    	public void setCheminCv(String cheminCv) {
    		this.cheminCv = cheminCv;
    	}
     
    	public String getCompetences() {
    		return competences;
    	}
     
    	public void setCompetences(String competences) {
    		this.competences = competences;
    	}
     
    	public String getDivers() {
    		return divers;
    	}
     
    	public void setDivers(String divers) {
    		this.divers = divers;
    	}
     
    	public Set<Formation> getFormations() {
    		return formations;
    	}
     
    	public void setFormations(Set<Formation> formations) {
    		this.formations = formations;
    	}
    }
    Formation.java
    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
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
     
    package modeles_candidat;
     
    // Generated 29 juil. 2010 14:21:09 by Hibernate Tools 3.2.2.GA
     
    import java.util.Date;
     
    import modeles_generale.NiveauFormation;
    import modeles_generale.TypeFormation;
     
    /**
     * Formation generated by hbm2java
     */
    public class Formation implements java.io.Serializable {
     
    	/**
             * 
             */
    	private static final long serialVersionUID = 1L;
    	private Integer idFormation;
    	private String titreFormation;
    	private String dateDebut;
    	private Date dateFin;
    	private String descriptionFormation;
    	private String etablissement;
    	private String ville;
    	private String paye;
    	private Candidat candidat;
    	private TypeFormation typeFormation;
    	private NiveauFormation nvFormation;
     
    	public Formation() {
    	}
     
    	public Formation(String titreFormation, String dateDebut, Date dateFin,
    			String descriptionFormation, String etablissement, String ville,
    			String paye, Candidat candidat, TypeFormation typeFormation,
    			NiveauFormation nvFormation) {
    		this.titreFormation = titreFormation;
    		this.dateDebut = dateDebut;
    		this.dateFin = dateFin;
    		this.descriptionFormation = descriptionFormation;
    		this.etablissement = etablissement;
    		this.ville = ville;
    		this.paye = paye;
    		this.candidat = candidat;
    		this.typeFormation = typeFormation;
    		this.nvFormation = nvFormation;
    	}
     
    	public Integer getIdFormation() {
    		return this.idFormation;
    	}
     
    	public void setIdFormation(Integer idFormation) {
    		this.idFormation = idFormation;
    	}
     
    	public String getTitreFormation() {
    		return this.titreFormation;
    	}
     
    	public void setTitreFormation(String titreFormation) {
    		this.titreFormation = titreFormation;
    	}
     
    	public String getDateDebut() {
    		return this.dateDebut;
    	}
     
    	public void setDateDebut(String dateDebut) {
    		this.dateDebut = dateDebut;
    	}
     
    	public Date getDateFin() {
    		return this.dateFin;
    	}
     
    	public void setDateFin(Date dateFin) {
    		this.dateFin = dateFin;
    	}
     
    	public String getDescriptionFormation() {
    		return this.descriptionFormation;
    	}
     
    	public void setDescriptionFormation(String descriptionFormation) {
    		this.descriptionFormation = descriptionFormation;
    	}
     
    	public String getEtablissement() {
    		return this.etablissement;
    	}
     
    	public void setEtablissement(String etablissement) {
    		this.etablissement = etablissement;
    	}
     
    	public String getVille() {
    		return this.ville;
    	}
     
    	public void setVille(String ville) {
    		this.ville = ville;
    	}
     
    	public String getPaye() {
    		return this.paye;
    	}
     
    	public void setPaye(String paye) {
    		this.paye = paye;
    	}
     
    	public void setCandidat(Candidat candidat) {
    		this.candidat = candidat;
    	}
     
    	public Candidat getCandidat() {
    		return candidat;
    	}
     
    	public void setTypeFormation(TypeFormation typeFormation) {
    		this.typeFormation = typeFormation;
    	}
     
    	public TypeFormation getTypeFormation() {
    		return typeFormation;
    	}
     
    	public void setNvFormation(NiveauFormation nvFormation) {
    		this.nvFormation = nvFormation;
    	}
     
    	public NiveauFormation getNvFormation() {
    		return nvFormation;
    	}
    }
    struts-config.xml
    Code xml : 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
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
                                   "http://struts.apache.org/dtds/struts-config_1_3.dtd">
    <struts-config>
     <data-sources/>
     <form-beans>
      <form-bean name="candidat" type="modeles_candidat.Candidat"/>
      <form-bean name="civilite" type="modeles_generale.Civilite"/>
      <form-bean name="cv" type="modeles_candidat.Cv"/>
     </form-beans>
     <global-exceptions/>
     <global-forwards/>
     <action-mappings>
      <action parameter="/inscription_candidat.jsp"
       path="/inscription_candidat" type="org.apache.struts.actions.ForwardAction"/>
      <action name="candidat" path="/creer_cv" scope="session" type="actions_candidat.Inscription_candidat">
       <forward name="succes" path="/creer_cv.jsp"/>
       <forward name="deny" path="/index.jsp"/>
      </action>
      <action name="cv" path="/creer_cv2" scope="request" type="actions_candidat.CV">
       <forward name="succes" path="/creer_cv2.jsp"/>
      </action>
     </action-mappings>
     <controller/>
    </struts-config>

    donc je veux savoir comment initialiser une propriété d'un objet dans une liste.
    Merci d'avance

  2. #2
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Comme tu as défini la classe Cv dans une balise form-bean du struts-config.xml, elle doit hériter d'ActionForm.
    Modératrice Java - Struts, Servlets/JSP, ...

  3. #3
    Futur Membre du Club
    Inscrit en
    Décembre 2008
    Messages
    9
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 9
    Points : 6
    Points
    6
    Par défaut
    Citation Envoyé par c_nvy Voir le message
    Comme tu as défini la classe Cv dans une balise form-bean du struts-config.xml, elle doit hériter d'ActionForm.
    Merci c_nvy pour votre réponse mais malheureusement j'ai toujours la même erreur

  4. #4
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Comment as-tu initialisé le HashSet formations ?
    Modératrice Java - Struts, Servlets/JSP, ...

  5. #5
    Futur Membre du Club
    Inscrit en
    Décembre 2008
    Messages
    9
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 9
    Points : 6
    Points
    6
    Par défaut
    Citation Envoyé par c_nvy Voir le message
    Comment as-tu initialisé le HashSet formations ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    private Set<Formation> formations = new HashSet<Formation>();

  6. #6
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Si le HashSet est vide à l'affichage de la jsp, il faut l'initialiser avec une instance de l'objet Formation dans la méthode reset de l'ActionForm.

    Sinon, pourquoi avoir choisi d'utiliser un HashSet plutôt qu'une ArrayList ?
    Modératrice Java - Struts, Servlets/JSP, ...

Discussions similaires

  1. Réponses: 0
    Dernier message: 19/05/2012, 18h03
  2. Réponses: 4
    Dernier message: 17/07/2007, 13h30
  3. [error] No getter method available..
    Par CPI_en_mousse dans le forum Struts 1
    Réponses: 9
    Dernier message: 05/07/2007, 11h03
  4. select dynamique : No getter method available
    Par salsoul dans le forum Struts 1
    Réponses: 7
    Dernier message: 09/05/2007, 23h31
  5. [Struts]No getter method for property xxx
    Par azpublic dans le forum Struts 1
    Réponses: 3
    Dernier message: 04/01/2006, 19h01

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